feat: add page.stealth_evaluate() for undetectable JS execution (#108)

Extract CDP isolated world classes from humanize layer into standalone
stealth_eval module. Attach page.stealth_evaluate(expression) to every
page automatically — runs JS in a CDP isolated world with clean
Error.stack traces and full variable isolation from main world JS.
This commit is contained in:
CloakHQ
2026-04-06 04:38:49 +02:00
parent 216a7d6a6a
commit a32d7c4eae
11 changed files with 639 additions and 262 deletions
+20
View File
@@ -138,6 +138,10 @@ def launch(
cfg = resolve_config(human_preset, human_config)
patch_browser(browser, cfg)
# Stealth evaluate — always attached
from .stealth_eval import patch_browser_stealth_eval
patch_browser_stealth_eval(browser, is_async=False)
return browser
@@ -227,6 +231,10 @@ async def launch_async( # noqa: C901
cfg = resolve_config(human_preset, human_config)
patch_browser_async(browser, cfg)
# Stealth evaluate — always attached
from .stealth_eval import patch_browser_stealth_eval
patch_browser_stealth_eval(browser, is_async=True)
return browser
@@ -344,6 +352,10 @@ def launch_persistent_context(
cfg = resolve_config(human_preset, human_config)
patch_context(context, cfg)
# Stealth evaluate — always attached
from .stealth_eval import patch_context_stealth_eval
patch_context_stealth_eval(context, is_async=False)
return context
@@ -463,6 +475,10 @@ async def launch_persistent_context_async(
cfg = resolve_config(human_preset, human_config)
patch_context_async(context, cfg)
# Stealth evaluate — always attached
from .stealth_eval import patch_context_stealth_eval
patch_context_stealth_eval(context, is_async=True)
return context
@@ -556,6 +572,10 @@ def launch_context(
cfg = resolve_config(human_preset, human_config)
patch_context(context, cfg)
# Stealth evaluate — always attached
from .stealth_eval import patch_context_stealth_eval
patch_context_stealth_eval(context, is_async=False)
return context