Last active
June 9, 2022 09:06
-
-
Save kosugi/6a47a7cab4ef41381f5d16c11b2137e4 to your computer and use it in GitHub Desktop.
IITC Plugin: Open In Scanner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @id iitc-plugin-open-in-scanner | |
| // @name IITC plugin: Open in Scanner | |
| // @category Portal Info | |
| // @version 0.0.0 | |
| // @namespace https://twitter.com/kosugip | |
| // @description Add “OpenInScanner” llink to portal info. | |
| // @author kosugip | |
| // @include https://*.ingress.com/intel* | |
| // @include http://*.ingress.com/intel* | |
| // @match https://*.ingress.com/intel* | |
| // @match http://*.ingress.com/intel* | |
| // @include https://intel.ingress.com/* | |
| // @include http://intel.ingress.com/* | |
| // @match https://intel.ingress.com/* | |
| // @match http://intel.ingress.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| 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 START //////////////////////////////////////////////////////// | |
| // use own namespace for plugin | |
| window.plugin.openInScanner = function() {}; | |
| window.plugin.openInScanner.setupCallback = function() { | |
| addHook('portalDetailsUpdated', window.plugin.openInScanner.addLink); | |
| } | |
| window.plugin.openInScanner.addLink = function(d) { | |
| var url = "https://link.ingress.com/?link=" + encodeURIComponent("https://intel.ingress.com/portal/" + d.guid); | |
| $('.linkdetails').append('<aside><a href="' + url + '">OpenInScanner</a></aside>'); | |
| } | |
| var setup = function () { | |
| window.plugin.openInScanner.setupCallback(); | |
| } | |
| // PLUGIN END ////////////////////////////////////////////////////////// | |
| setup.info = plugin_info; //add the script info data to the function as a property | |
| if(!window.bootPlugins) window.bootPlugins = []; | |
| window.bootPlugins.push(setup); | |
| // if IITC has already booted, immediately run the 'setup' function | |
| if(window.iitcLoaded && typeof setup === 'function') setup(); | |
| } // wrapper end | |
| // inject code into site context | |
| var script = document.createElement('script'); | |
| 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment