The only change was wrapping the function with exportFunction(new Proxy(...), unsafeWindow) so that it works properly in Firefox under some scenarios, for instance for those like me using FireMonkey extension instead of Violentmonkey. It will still be compatible compatible with Violentmonkey and Chrome, don't worry.
This is needed because Firefox has a security layer so that window in UserScripts context is different than window in page context (aka unsafeWindow). In this case, objects and functions defined in UserScript have restricted access in page context unless they are exported using exportFunction (for functions) or cloneInto (for objects).
Proposed change to increase compatibility
Thanks for the script. I suggest using this code:
The only change was wrapping the function with
exportFunction(new Proxy(...), unsafeWindow)
so that it works properly in Firefox under some scenarios, for instance for those like me using FireMonkey extension instead of Violentmonkey. It will still be compatible compatible with Violentmonkey and Chrome, don't worry.This is needed because Firefox has a security layer so that
window
in UserScripts context is different thanwindow
in page context (akaunsafeWindow
). In this case, objects and functions defined in UserScript have restricted access in page context unless they are exported usingexportFunction
(for functions) orcloneInto
(for objects).