Open NCGSolutions opened 2 weeks ago
In Camoufox, all of Playwright's JavaScript runs in an isolated context. This prevents Playwright from running JavaScript that writes to the main world/context of the page.
While this is helpful with preventing detection of the Playwright page agent, it causes some issues with native Playwright functions like setting file inputs, executing JavaScript, adding page init scripts, etc. These features might need to be implemented separately.
A current workaround for this might be to create a small dummy addon to inject into the browser.
Thanks for reporting this!
Describe the bug:
Scripts are not being properly injected/attached(?) to the browser context via add_init_script. I provide an example below that I use to open Closed Shadow DOMs but it can be reproduced with any script needed to be added via add_init_script.
To Reproduce:
Run code below, that shows that the add_init_script function works differently for playwright versus camoufox!
main.py
shadow_root.js
(function() { const originalAttachShadow = Element.prototype.attachShadow; Element.prototype.attachShadow = function() { return originalAttachShadow.call(this, { mode: 'open' }); }; })();
closed_shadow_root.html
Version:
Pip package: v0.3.0 Camoufox: v130.0.1-beta.13 (Up to date!)
Note:
This should also solve this issue as well! https://github.com/daijro/camoufox/issues/2