-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compatibility with Violentmonkey #64
Conversation
…ility with violentmonkey
Violentmonkey seems to be strict about that; I was picking through it and able to resolve that part by wrapping it in an async function:
But applying your fix above seems to clear the first issue, but I'm getting issues with |
To clarify my comment, this allows the JSON to be processed, but I don't think any of the options function because |
Seems to occur when any of the mods calls |
Hmm, I'm not seeing any settings that'd affect that unless I'm missing something |
Have a look at this: violentmonkey/violentmonkey#173 I tried violentmonkey's various injection modes, but none of them worked unless explicitly doing this: OLD:
NEW:
Second method works, all settings load. However, I don't remember all of the implications of this, so don't think it's a good idea to include this in the normal script. Nor did I test every interaction of elements. I think To better identify the problem surface: does this only affect VM + Firefox? Does the same script in VM + e.g. Chrome work when using VM's "auto" page injection context? (Can you test that?) It seems related to Firefox's stricter CSP policy. |
I get the same issue in Chrome with VM. Is there a way to pass the function to the mods so they have access to it in their namespace? This is a bit beyond my JS knowledge |
I think this should fix it and is a fairly vanilla approach:
Should bind it to the global window context and allow this one function to be seen by the scope of the others. I think the "unsafewindow" is a bit of a misnomer in that it's widely supported and modern browser should already be isolating injected JS from self JS. I think it used to be the case that pages could "see" a third party script this way, but that should be ancient history by now sandboxing is already taking place. Some additional discussion here: https://stackoverflow.com/questions/65552070/why-do-userscript-managers-still-suport-the-use-of-unsafewindow |
I have pushed the fix, please have a look. Also, looks like your collapsed comments mod is calling |
I'll fix that real quick, we should add a note in the documentation to only use |
Looks like your fix is working |
That makes sense, probably suggest TM over VM and GM just because it's the most feature complete and mature at this point, but that's a great idea, will look into adding it to a testing suite that will prevent these kinds of things from inadvertently making their way in. |
I removed the (apparently nonfunctional) await on line 133, and replaced all of the
GM.
functions withGM_
functions, as violentmonkey doesn't have those built inFixes #63