Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @id iitc-plugin-highlight-portals-missing-resonators@vita10gy
- // @name IITC plugin: highlight portals with more fields than links
- // @category Highlighter
- // @version 0.1.2.20150414.12303
- // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
- // @description [jonatkins-test-2015-04-14-012303] Use the portal fill color to denote if the portal has more fields than links.
- // @include https://www.ingress.com/intel*
- // @include http://www.ingress.com/intel*
- // @match https://www.ingress.com/intel*
- // @match http://www.ingress.com/intel*
- // @include https://www.ingress.com/mission/*
- // @include http://www.ingress.com/mission/*
- // @match https://www.ingress.com/mission/*
- // @match http://www.ingress.com/mission/*
- // @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.portalsMoreFeldsThanLinks = function() {};
- window.plugin.portalsMoreFeldsThanLinks.highlight = function(data) {
- var fill_opacity = 0.7;
- var color = undefined;
- var portalLinksCount = -1;
- var portalFieldsCount = -1;
- // Totally wrong? Always returns 0 as result ...
- portalLinksCount = window.getPortalLinksCount(data.portal.options.guid);
- portalFieldsCount = window.getPortalFieldsCount(data.portal.options.guid);
- // Debug (see comment above)
- console.log("portalLinksCount: %d", portalLinksCount);
- console.log("portalFieldsCount: %d", portalFieldsCount);
- if(data.portal.options.team != TEAM_NONE) {
- if(portalFieldsCount > portalLinksCount) {
- var color = 'red';
- var params = {fillColor: color, fillOpacity: fill_opacity};
- data.portal.setStyle(params);
- }
- }
- }
- window.plugin.portalsMoreFeldsThanLinks.highlight.setSelected = function(selected) {
- window.plugin.portalsMoreFeldsThanLinks.isSelected=selected;
- }
- window.plugin.portalsMoreFeldsThanLinks.mapRefreshEnd = function() {
- if (window.plugin.portalsMoreFeldsThanLinks.isSelected) {
- resetHighlightedPortals();
- }
- }
- var setup = function() {
- window.plugin.portalsMoreFeldsThanLinks.isSelected = false;
- window.addPortalHighlighter('Portals With More Fields than Links', window.plugin.portalsMoreFeldsThanLinks.highlight);
- }
- // 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement