IITC plugin: Highlight portals by level

Highlight portals by level

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @author         Odrick
// @name           IITC plugin: Highlight portals by level
// @description    Highlight portals by level
// @category       Highlighter
// @version        0.0.1
// @id             highlight-portals-by-level
// @match          https://*.ingress.com/intel*
// @match          http://*.ingress.com/intel*
// @match          https://*.ingress.com/mission/*
// @match          http://*.ingress.com/mission/*
// @include        https://*.ingress.com/intel*
// @include        http://*.ingress.com/intel*
// @include        https://*.ingress.com/mission/*
// @include        http://*.ingress.com/mission/*
// @grant          none
// @namespace https://greasyfork.org/users/410740
// ==/UserScript==

function wrapper(plugin_info) {

if(typeof window.plugin !== 'function') window.plugin = function() {};

plugin_info.buildName = 'odrick@highlight-portals-by-level';
plugin_info.dateTimeVersion = '2020-05-19-160405';
plugin_info.pluginId = 'highlight-portals-by-level';

window.plugin.highlightPortalsByLevel = function() {};

function highlight(data, level) {
  if (data.portal.options.data.level === level) {
    data.portal.setStyle({fillColor: '#ff0000', fillOpacity: 0.75});
  }
}

window.plugin.highlightPortalsByLevel.colorLevel1 = function(data) {highlight(data, 1)};
window.plugin.highlightPortalsByLevel.colorLevel2 = function(data) {highlight(data, 2)};
window.plugin.highlightPortalsByLevel.colorLevel3 = function(data) {highlight(data, 3)};
window.plugin.highlightPortalsByLevel.colorLevel4 = function(data) {highlight(data, 4)};
window.plugin.highlightPortalsByLevel.colorLevel5 = function(data) {highlight(data, 5)};
window.plugin.highlightPortalsByLevel.colorLevel6 = function(data) {highlight(data, 6)};
window.plugin.highlightPortalsByLevel.colorLevel7 = function(data) {highlight(data, 7)};
window.plugin.highlightPortalsByLevel.colorLevel8 = function(data) {highlight(data, 8)};

var setup =  function() {
  window.addPortalHighlighter('Level 1', window.plugin.highlightPortalsByLevel.colorLevel1);
  window.addPortalHighlighter('Level 2', window.plugin.highlightPortalsByLevel.colorLevel2);
  window.addPortalHighlighter('Level 3', window.plugin.highlightPortalsByLevel.colorLevel3);
  window.addPortalHighlighter('Level 4', window.plugin.highlightPortalsByLevel.colorLevel4);
  window.addPortalHighlighter('Level 5', window.plugin.highlightPortalsByLevel.colorLevel5);
  window.addPortalHighlighter('Level 6', window.plugin.highlightPortalsByLevel.colorLevel6);
  window.addPortalHighlighter('Level 7', window.plugin.highlightPortalsByLevel.colorLevel7);
  window.addPortalHighlighter('Level 8', window.plugin.highlightPortalsByLevel.colorLevel8);
}

setup.info = plugin_info;
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);