From 9dabc33770d6d85629c85fbf271186be1e341efd Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 29 Oct 2013 02:43:56 +0000 Subject: [PATCH] modify plugin wrapper, so build-script injected macros in the wrapper are in a more obvious place, so 3rd party plugin authors are less likely to make mistakes here when working outside the build.py environment tweak the about screen to display non-standard plugins using the new interface better --- build.py | 11 +++++++++-- code/utils_misc.js | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index abde15f2..f81f6245 100755 --- a/build.py +++ b/build.py @@ -71,6 +71,13 @@ function wrapper(plugin_info) { // ensure plugin framework is there, even if iitc is not yet loaded if(typeof window.plugin !== 'function') window.plugin = function() {}; +//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! +//(leaving them in place might break the 'About IITC' page or break update checks) +plugin_info.buildName = '@@BUILDNAME@@'; +plugin_info.dateTimeVersion: '@@DATETIMEVERSION@@'; +plugin_info.pluginId = '@@PLUGINNAME@@'; +//END PLUGIN AUTHORS NOTE + """ pluginWrapperEnd = """ @@ -82,8 +89,8 @@ if(window.iitcLoaded && typeof setup === 'function') setup(); } // wrapper end // inject code into site context var script = document.createElement('script'); -var info = { buildName: '@@BUILDNAME@@', dateTimeVersion: '@@DATETIMEVERSION@@', pluginId: '@@PLUGINNAME@@' }; -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 }; +var info = {}; +if (typeof GM_info !== 'undefined' && GM_info && 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); diff --git a/code/utils_misc.js b/code/utils_misc.js index 762e5fa1..f41755e5 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -18,7 +18,7 @@ window.aboutIITC = function() { var ptext = pname + ' - ' + pvers; if (info.buildName != script_info.buildName) { - ptext += ' ['+info.buildName+']'; + ptext += ' ['+(info.buildName||'non-standard plugin')+']'; } plugins += '
  • '+ptext+'
  • ';