Skip to content

Instantly share code, notes, and snippets.

@isnot
Last active October 8, 2016 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isnot/db545fd5cc314163f9b828f16ed63d64 to your computer and use it in GitHub Desktop.
Save isnot/db545fd5cc314163f9b828f16ed63d64 to your computer and use it in GitHub Desktop.
iitc-plugin-show-zoom-level
// ==UserScript==
// @id iitc-plugin-show-zoom-level@isnot
// @name IITC plugin: show zoom level
// @category Controls
// @version 0.1
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @author isnot
// @updateURL none
// @downloadURL none
// @description [iitc-plugins] Indicate zoom level on map.
// @include https://*.ingress.com/intel*
// @include http://*.ingress.com/intel*
// @match https://*.ingress.com/intel*
// @match http://*.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 ////////////////////////////////////////////////////////
var setup = function() {
$('#updatestatus').append('<div title="Map Zoom Level" id="iitc-plugin-zoomLevel">z</div>');
$('<style>')
.prop('type', 'text/css')
.html('#iitc-plugin-zoomLevel {align:right; height:15px; width:30px; bottom:0; padding:4px; position:fixed; right:0; z-index:3003; background:#ffd1d1; color:#663300};')
.appendTo('head');
window.addHook('mapDataEntityInject', function() {
$("#iitc-plugin-zoomLevel").html('z' + map.getZoom());
});
window.addHook('mapDataRefreshEnd', function() {
$("#iitc-plugin-zoomLevel").html('z' + map.getZoom());
});
};
// 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