CamouBrowser Docs

Main World Execution

Camoufox only

This page describes Camoufox. Camouwolf accepts main_world_eval for compatibility, but there is nothing to enable: Playwright on Chromium already evaluates in the page's main world, with or without the mw: prefix (which JavaScript reads as a label), and an isolated-world evaluate is not available. The leak warning below therefore applies to every evaluate in Camouwolf.


Reading the DOM - Isolated World

In Camoufox, all JavaScript execution is ran in an isolated scope by default, invisible to the page.

This makes it impossible for the page to detect your JavaScript reading the DOM:

>>> page.goto("https://example.com/")
>>> page.evaluate("document.title")
'Example Domain'

The isolated world shares the page's DOM, but not its JavaScript. Your code can't see the page's own variables and functions, and the page can't see yours:

>>> page.evaluate("typeof window.pageValue")  # a variable the page's scripts set
'undefined'

Changes you make to the DOM from the isolated world do reach the page, and the page can observe them (for example with a MutationObserver).


Page JavaScript - Main World

To reach the page's own JavaScript (its variables, functions and overridden APIs), run your code in the main world, the non-isolated scope.

Leak Warning

All code executed in the main world can be detected by the target website. Only execute JavaScript in the main world if absolutely necessary.


To enable main world execution, set the main_world_eval parameter to True:

with Camoufox(main_world_eval=True) as browser:
    page = browser.new_page()
    page.goto("https://example.com/")

Now, you can run JavaScript in the main world by prefixing the code with mw:

>>> page.evaluate("mw:window.pageValue = 42")
>>> page.evaluate("mw:window.pageValue")
42
>>> page.evaluate("mw:document.querySelector('p').remove()")
# The first paragraph is now removed

You can also return JSON serializable data from the main world. Wrap an object literal in parentheses, or it is read as a block:

>>> page.evaluate("mw:({key: 'value'})")
{'key': 'value'}

Note

Returning references to nodes/elements from the main world is not supported, since Playwright's utilities do not run in the main world.
To retrieve node references, use the isolated world instead.

© Copyright daijro 2026. All rights reserved.