Created
January 11, 2016 03:28
-
-
Save neon-ninja/c51dd249b214a1f88027 to your computer and use it in GitHub Desktop.
IITC Player Tracker Names
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-player-tracker-names | |
// @name IITC Player Tracker Names | |
// @category Tweaks | |
// @version 1.0 | |
// @description This plugin displays player names for player tracker | |
// @include https://www.ingress.com/intel* | |
// @include http://www.ingress.com/intel* | |
// @match https://www.ingress.com/intel* | |
// @match http://www.ingress.com/intel* | |
// @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 //////////////////////////////////////////////////////// | |
window.plugin.playerTrackerNames = function() {}; | |
window.plugin.playerTrackerNames.setupHook = function() { | |
// override setupTooltips so that multiple tooltips can be open at once | |
window.setupTooltips = function(element) { | |
element = element || $(document); | |
element.tooltip({ | |
content: function() { | |
var title = $(this).attr('title'); | |
return window.convertTextToTableMagic(title); | |
}, | |
close: function(event, ui) { | |
setTimeout(function() { | |
$(event.target).tooltip('open'); | |
}, 3000); | |
}, | |
}); | |
element.tooltip('open'); | |
} | |
$(document).tooltip('destroy'); | |
window.setupTooltips(); | |
$("<style>").prop("type", "text/css").html(".ui-tooltip {z-index: 1000 !important}").appendTo("head"); | |
} | |
window.plugin.playerTrackerNames.setup = function() { | |
if (window.plugin.playerTracker === undefined) { | |
console.log("This plugin requires player tracker"); | |
return; | |
} | |
// Ensure this hook gets run after player tracker's | |
addHook('iitcLoaded', window.plugin.playerTrackerNames.setupHook); | |
}; | |
var setup = window.plugin.playerTrackerNames.setup; | |
// 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
Love it!