-
Notifications
You must be signed in to change notification settings - Fork 553
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
Questions about plugin structure #1298
Comments
If you look at the code of any plugin you will notice that each plugin is in a function. Code of the plugins is not executed at once. It will wait for IITC to load. There is also some integration with GM_info which gives you script information. Namespaces are important as there are many plugins out there. But you don't have to create your namespace if the plugin is to be fully private (no public methods nor properties). |
@Eccenux, more discussion here: IITC-CE/ingress-intel-total-conversion#46
Yes, and I try to understand the reason: why it's function?
And even more, it would be cleaner if defined like this:
Could you explain further? |
For both isolation and delayed execution (interpretation) of the code. Note that just below user script template you have GM_info available, and inside the wrapper the context changes. The code is run in context of the site not in a Tampermonkey context. Did it really had to be done like that?... I'm not sure. TM does provide some isolation, but then you might need to use |
Actually I asked another question:
Why is it a function? Why not plain object?
You are talking about wrapper purpose.
Here I do not agree, and for Tampermonkey we can completely omit the part after wrapper ('inject code into site context'). You can try yourself: IITC-CE/ingress-intel-total-conversion#51. |
Not sure what you are asking here... It's just a convention I guess. Technically you don't need that at all. You can just write a class and export objects you need or export nothing... But when you don't export anything then other plugins might not be able to detect your plugin and plugins will not be able to interact with each other (like e.g. sync and uniques and bookmarks). Example of exporting a function when you need to: https://github.com/Eccenux/iitc-plugin-data-merger/blob/v0.3.0/data-merger.user.js#L170
Greasemonkey is dead (died with introduction of FF Quantum). It's not supported in new browsers AFAIK. The Also note that your assumptions in IITC-CE/ingress-intel-total-conversion#51 are incorrect. Plugins don't polute global namespace unless you make them. This is not how it works. Try to run Sorry, but are you sure you have enough experience with JavaScript and user scripts to mess with how ITTC works? This is a delicate matter. I alone have more then 10 custom plugins and I know there are more out there. |
Well, I am trying to find a point why it is like that.
Look again at
Shouldn't we still support legacy Firefox users?
I am not going to remove anything until I'm make sure that it's safe. That's why we discussing it.
Open console and see
I'll do my best, thank you. And you could participate if you are interested. I use some of your plugins and appreciate your experience with iitc. |
You can see it in mobile console.
Sure it is, though now in Tampermonkey we could keep things simpler. |
ingress-intel-total-conversion/plugins/default-intel-detail.user.js
Lines 26 to 37 in f904527
There is anonymous function in assignment:
window.plugin.defaultIntelDetail.setup = function()
. But would it be better to use functions names in order to see them in debugger?Why do we ever need
own namespace for plugin
?I can understand if there is demand for cross-plugin data access, but here is definitely not that case.
Why do we ever need to store private functions in namespace?
Why do not write just like that:
The text was updated successfully, but these errors were encountered: