-
Notifications
You must be signed in to change notification settings - Fork 109
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
revise wrapper #51
revise wrapper #51
Conversation
485fbde
to
f34a8f7
Compare
- Do not try to 'inject script in site context' anymore, as it has no observable effect (if I haven't missed something). Thus wrapper is simpler now. - It's now real IIFE, and does not pollute global namespace with `wrapper`, `script`, `info` and so on. - No need to cut that 'inject' part of wrapper for mobile app.
f34a8f7
to
2bea635
Compare
I suppose the wrapper could be even more simplified. |
In my plugin for Pokemon Go, I avoided the usage of the wrapper and everything looked to work fine (and it's easier to work and debug because the code is run directly instead of reinjected as a script), and the only problem has been a recent report about not working with Greasemonkey that seemed to require this workaround due to the "unsafeWindow" |
It's a matter of coincidence, as wrapper is really needed in order to:
Try to reorder scripts loading order in Tampermonkey and see what may happen. |
No, it doesn't matter the plugin order as the initialization is run in the "setup" function and it detects if iitc is ready or it should add itself to the list of pending plugins: https://gitlab.com/AlfonsoML/pogo-s2/blob/master/s2check.user.js#L3013 |
Ah, now I see what you mean.
This part is exactly what I call 'wrapper', and it is followed by one more part, which is intended to
Thank you for sharing this info. I need to try Firefox. |
Ok, I just called the 'wrapper' to the function that it's called 'wrapper' by default in all the IITC plugins 😀and that it's then use to inject the code again in the site context. I'm not talking at all about the "setup" According to my tests, whenever people use Tampermonkey (with Chrome, Firefox or even Edge), then you don't need the hoop to reinject the code into the site context, but it turns out that it's required for Greasemonkey (which used to be the reference long ago, so that can explain why the code is structured the way that it is). I would not create separate options to insert different wrappers, otherwise you end up with "install this for tampermonkey and this for greasemonkey" and the only difference are a few lines that can take care of this difference automatically |
Perhaps, better I'll comment on here, not in #124 Page context and context extension (that loads UserScripts) different. This is a limitation of the browser sandbox. To run the code in the context of the page, a wrapper is used. Maybe it makes sense to abandon Greasemonkey and write simpler code without using a wrapper. |
What exactly feature do you mean?
May be it's possible to replace that 'injection' with some better technique, recommended for extensions.
Well, there is also Violentmonkey, etc. |
Actually I have no experience in extensions development, and do not know where exactly we really dependent on page context, and where it is just a matter of legacy code (you know, currently So after we reorganize API (e.g. we could pass API object into |
Use window object as if the script is already running in the context of the page. For example, the ingressmosaik plugin in extension context get window.plugin.missions and window.dialog (which are available in tampermonkey but are actually in the context of page) and only if all is well then goes into the context of page.
Yes, now IITC-Button works by Greasemonkey method By the way, recently Firefox has a new API for UserScripts, but we need its support in Chrome |
No, that plugins not really use any feature, at least intentionally. I saw ingressmosaic plugin and can tell that it's author just 'reinvent' buggy substitution for I don't feel that we should support plugins bugs. Better fix such plugins.
It does not seem to be something different from greasemonkeys's current, I mean there will not be lesser restrictions. |
Well. Then, if there will be hooks, we can continue to support GM |
What hook do you mean? |
Ah, there's already has iitcLoaded. Okay |
Yes, and I am even going to replace it with more reliable Promise (#76). Edit: in most cases we do need |
Discussion about pure and fair GM support will be continued here: #124 (comment) |
As for this PR:
|
I just realized that it's not true, as IITC-Button does not need wrapper at all. Literally, it even can cut it out like IITCm does. |
Could you explain why it's easier to debug scripts without wrapper? |
Oh, I've got it. |
Superseeded by #358 |
!Proof-of-concept branch
(to be merged after we'll make sure that there be no undesirable side-effects)
as it has no observable effect (if I haven't missed something).
Thus wrapper is simpler now.
wrapper
,script
,info
and so on.