extract script version and other data from the tampermonkey/greasemonkey GM_info and pass it through the wrapper function
modify the plugin template code to do the same for plugins - also include the plugin base filename this is the required data to allow version checks to be performed. it will also allow IITC to know which plugins are installed and active
This commit is contained in:
10
main.js
10
main.js
@ -107,7 +107,11 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
||||
// putting everything in a wrapper function that in turn is placed in a
|
||||
// script tag on the website allows us to execute in the site’s context
|
||||
// instead of in the Greasemonkey/Extension/etc. context.
|
||||
function wrapper() {
|
||||
function wrapper(info) {
|
||||
// a cut-down version of GM_info is passed as a parameter to the script
|
||||
// (not the full GM_info - it contains the ENTIRE script source!)
|
||||
window.script_info = info;
|
||||
|
||||
|
||||
// LEAFLET PREFER CANVAS ///////////////////////////////////////////////
|
||||
// Set to true if Leaflet should draw things using Canvas instead of SVG
|
||||
@ -240,5 +244,7 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
|
||||
// inject code into site context
|
||||
var script = document.createElement('script');
|
||||
script.appendChild(document.createTextNode('('+ wrapper +')();'));
|
||||
var info = { buildName: '@@BUILDNAME@@', dateTimeVersion: '@@DATETIMEVERSION@@' };
|
||||
if (this.GM_info && this.GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
|
||||
script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
|
||||
(document.body || document.head || document.documentElement).appendChild(script);
|
||||
|
Reference in New Issue
Block a user