IITC-CE / ingress-intel-total-conversion

intel.ingress.com total conversion user script with some new features. Should allow easier extension of the intel map.
https://iitc.app
ISC License
279 stars 105 forks source link

GreaseMonkey support #124

Open johnd0e opened 5 years ago

johnd0e commented 5 years ago
modos189 commented 5 years ago

I use GreaseMonkey on a regular basis, everything is OK

johnd0e commented 5 years ago

GM v4? Great.

I have to install it too, in order to resolve #51.

modos189 commented 5 years ago

Yes, v4.7.

Previously added this fix to work.

johnd0e commented 5 years ago

As step to more native support of GM, we can consider some iitc api extensions.

  1. Eliminate window object usage (outside of setup). The only thing that is absolutely needed: fair way to transfer plugin's setup to common context (currently it's done via bootPlugins array).

    • Instead of script node injection we may consider to postMessage with the same stringified wrapper. The message should be processed then under full control of the main iitc script.
  2. Existent plugins could be make compatible with new scheme just by replacing wrapper code. Bare minimum: window must be defined in wrapper as private empty object, and then attached to setup as it's property.

    Like this ```iitc-plugin.user.js (function (window) { // ... function setup (iitc, window) { // ... } // ... setup.window = window; }({})) ```
  3. Actual IITC api can be passed to setup as parameter.

    Like this ```total-conversion-build.user.js // ... var setup = bootplugins[i]; L.extend(commonWindow, setup.window); try { setup(iitc, commonWindow); } catch (e) { // ... } ```

It is breaking change, as we need to all existent plugins. But: