Last active
June 2, 2022 02:41
-
-
Save cockok/838db8158bd48b1b3c255f15ccef6e50 to your computer and use it in GitHub Desktop.
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-dynamic-link | |
// @name IITC plugin: Dynamic link | |
// @category Portal Info | |
// @version 0.1.0 | |
// @updateURL https://gist.github.com/cockok/838db8158bd48b1b3c255f15ccef6e50/raw/iitc-plugin-dynamic-link.user.js | |
// @downloadURL https://gist.github.com/cockok/838db8158bd48b1b3c255f15ccef6e50/raw/iitc-plugin-dynamic-link.user.js | |
// @namespace https://github.com/cockok | |
// @description Add Dynamic link to iitc | |
// @include https://*.ingress.com/intel* | |
// @include http://*.ingress.com/intel* | |
// @match https://*.ingress.com/intel* | |
// @match http://*.ingress.com/intel* | |
// @author cockok <[email protected]> | |
// @grant none | |
// ==/UserScript== | |
function wrapper(plugin_info) { | |
if (typeof window.plugin !== 'function') window.plugin = function() {}; | |
plugin_info.dateTimeVersion = '20220601.000000'; | |
plugin_info.pluginId = 'dynamicLink'; | |
window.plugin.dynamicLink = function() {}; | |
window.plugin.dynamicLink.setupCallback = function() { | |
addHook('portalDetailsUpdated', window.plugin.dynamicLink.addLink); | |
}; | |
window.plugin.dynamicLink.addLink = function(d) { | |
$('.linkdetails').append( | |
'<aside><a href="https://link.ingress.com/' | |
+ '?link=' + encodeURI('https://intel.ingress.com/portal/' + d.guid) | |
+ '&apn=com.nianticproject.ingress' | |
+ '&isi=576505181' | |
+ '&ibi=com.google.ingress' | |
+ '&ifl=' + encodeURI('https://apps.apple.com/app/ingress/id576505181') | |
+ '&ofl=' + encodeURI('https://intel.ingress.com/intel?pll=' + d.portal._latlng.lat.toFixed(6) + ',' + d.portal._latlng.lng.toFixed(6)) | |
+ '" title="Dynamic Link" target="_blank">Dynamic link</a></aside>' | |
); | |
}; | |
var setup = function() { | |
window.plugin.dynamicLink.setupCallback(); | |
}; | |
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 (window.iitcLoaded && typeof setup === 'function') setup(); | |
} | |
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