IITC plugin: route planner

Route planner

当前为 2020-04-03 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        IITC plugin: route planner
// @version     0.0.2
// @author      Odrick
// @description Route planner
// @match       https://*.ingress.com/intel*
// @match       http://*.ingress.com/intel*
// @match       https://*.ingress.com/mission/*
// @match       http://*.ingress.com/mission/*
// @id          iitc-plugin-route-planner@odrick
// @category    Layer
// @license     MIT
// @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(n){var e={};function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:r})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(r,o,function(e){return n[e]}.bind(null,o));return r},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=3)}([function(n,e,t){var r=t(4);n.exports="string"==typeof r?r:r.toString()},function(n,e,t){var r=t(6);n.exports="string"==typeof r?r:r.toString()},function(n,e){n.exports=function(n,e,t,r){var o=new Blob(void 0!==r?[r,n]:[n],{type:t||"application/octet-stream"});if(void 0!==window.navigator.msSaveBlob)window.navigator.msSaveBlob(o,e);else{var i=window.URL&&window.URL.createObjectURL?window.URL.createObjectURL(o):window.webkitURL.createObjectURL(o),a=document.createElement("a");a.style.display="none",a.href=i,a.setAttribute("download",e),void 0===a.download&&a.setAttribute("target","_blank"),document.body.appendChild(a),a.click(),setTimeout((function(){document.body.removeChild(a),window.URL.revokeObjectURL(i)}),0)}}},function(n,e,t){n.exports=t(7)},function(n,e,t){(e=t(5)(!1)).push([n.i,"#routePlannerBox {\r\n\tdisplay: none;\r\n\tposition: absolute!important;\r\n\tz-index: 5002;\r\n\ttop: 50px;\r\n\tleft: 60px;\r\n\twidth: 300px;\r\n\toverflow: hidden;\r\n\tbackground: rgba(8, 48, 78, .9);\r\n\tborder: 1px solid #20a8b1;\r\n\tcolor: #ffffff;\r\n\tpadding: 8px;\r\n\tfont-size: 13px;\r\n\t-webkit-touch-callout: none;\r\n\t-webkit-user-select: none;\r\n\t-khtml-user-select: none;\r\n\t-moz-user-select: none;\r\n\t-ms-user-select: none;\r\n\tuser-select: none\r\n}\r\n\r\n#routePlannerBox a.btn {\r\n    color: #ffce00;\r\n}\r\n\r\n#routePlannerBox #routePlannerTopBar {\r\n\theight: 15px!important\r\n}\r\n\r\n#routePlannerBox #routePlannerTopBar * {\r\n\theight: 14px!important\r\n}\r\n\r\n#routePlannerBox .handle {\r\n\twidth: 89%;\r\n\ttext-align: center;\r\n\tcolor: #fff;\r\n\tline-height: 6px;\r\n\tcursor: move;\r\n\tfloat: right\r\n}\r\n\r\n#routePlannerBox #routePlannerTopBar .btn {\r\n\tdisplay: block;\r\n\twidth: 10%;\r\n\tcursor: pointer;\r\n\tcolor: #20a8b1;\r\n\tfont-weight: 700;\r\n\ttext-align: center;\r\n\tline-height: 13px;\r\n\tfont-size: 18px;\r\n\tborder: 1px solid #20a8b1;\r\n\tfloat: left\r\n}\r\n\r\n#routePlannerBox #routePlannerTopBar .btn:hover {\r\n\tcolor: #ffce00;\r\n\ttext-decoration: none\r\n}\r\n\r\n#routePlannerBox #routePlannerTitle {\r\n\tfont-size: 14px;\r\n    padding-top: 5px;\r\n    color: #0099ff;\r\n}\r\n\r\n#importInput {\r\n    visibility: hidden;\r\n    width: 20px;\r\n    height: 10px;\r\n}\r\n\r\n#routePlannerToolBox {\r\n    clear: both;\r\n    padding: 2px;\r\n    text-align: right;\r\n}\r\n\r\n#routePlannerList {\r\n    width: 300px;\r\n    height: 350px;\r\n    margin: auto;\r\n    border: 1px solid #20a8b1;\r\n    overflow-x: hidden;\r\n    overflow-y: auto;\r\n    margin-top: 4px;\r\n    clear: both;\r\n}\r\n\r\n.routePlannerListItem {\r\n    cursor: pointer;\r\n}\r\n\r\n.routePlannerListItemTitle {\r\n    display: inline-block;\r\n    padding-left: 4px;\r\n    width: 250px;\r\n    overflow: hidden;\r\n    box-sizing: border-box;\r\n    white-space: nowrap;\r\n}\r\n\r\n.routePlannerListItemControls {\r\n    display: inline-block;\r\n    text-align: center;\r\n    width: 20px;\r\n    overflow: hidden;\r\n    white-space: nowrap;\r\n}\r\n\r\n#routePlannerLinks {\r\n    min-height: 10px;\r\n    padding-top: 8px;\r\n}",""]),n.exports=e},function(n,e,t){"use strict";n.exports=function(n){var e=[];return e.toString=function(){return this.map((function(e){var t=function(n,e){var t=n[1]||"",r=n[3];if(!r)return t;if(e&&"function"==typeof btoa){var o=(a=r,l=btoa(unescape(encodeURIComponent(JSON.stringify(a)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),"/*# ".concat(u," */")),i=r.sources.map((function(n){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(n," */")}));return[t].concat(i).concat([o]).join("\n")}var a,l,u;return[t].join("\n")}(e,n);return e[2]?"@media ".concat(e[2]," {").concat(t,"}"):t})).join("")},e.i=function(n,t,r){"string"==typeof n&&(n=[[null,n,""]]);var o={};if(r)for(var i=0;i<this.length;i++){var a=this[i][0];null!=a&&(o[a]=!0)}for(var l=0;l<n.length;l++){var u=[].concat(n[l]);r&&o[u[0]]||(t&&(u[2]?u[2]="".concat(t," and ").concat(u[2]):u[2]=t),e.push(u))}},e}},function(n,e){n.exports='<div id="routePlannerBox">\r\n    <div id="routePlannerTopBar">\r\n        <a id="routePlannerMin" class="btn" onclick="window.plugin.routePlanner.hideBox();return false;" title="Minimize">-</a>\r\n        <div class="handle"><div id="routePlannerTitle" class="ui-dialog-title ui-dialog-title-active">Route planner</div></div>\r\n    </div>\r\n    <div id="routePlannerToolBox">\r\n        <input type="file" id="importInput" visbility="hidden" onchange="window.plugin.routePlanner.doImport();return false;"/>\r\n\r\n        <a href="#" onclick="window.plugin.routePlanner.copy();return false;">Copy</a>\r\n        ::\r\n        <a href="#" onclick="window.plugin.routePlanner.export();return false;">Export</a>\r\n        ::\r\n        <a href="#" onclick="window.plugin.routePlanner.import();return false;">Import</a>\r\n        ::\r\n        <a href="#" onclick="window.plugin.routePlanner.clear();return false;">Clear</a>\r\n    </div>\r\n    <div id="routePlannerList"></div>\r\n    <div id="routePlannerLinks"></div>\r\n</div>'},function(n,e,t){"use strict";t.r(e);var r=t(0),o=t.n(r),i=t(1),a=t.n(i),l=t(2),u=t.n(l);function c(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}var d=function(){function n(){!function(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n)}var e,t,r;return e=n,r=[{key:"downloadFile",value:function(n,e){u()(n,e)}},{key:"ui",get:function(){return a.a}},{key:"css",get:function(){return o.a}}],(t=null)&&c(e.prototype,t),r&&c(e,r),n}();window.RoutePlannerPluginUtils=d;var p=document.createElement("script"),s={};"undefined"!=typeof GM_info&&GM_info&&GM_info.script&&(s.script={version:GM_info.script.version,name:GM_info.script.name,description:GM_info.script.description});var f=document.createTextNode("("+function(n){"function"!=typeof window.plugin&&(window.plugin=function(){}),n.buildName="Route planner",n.dateTimeVersion="20200402163000",n.pluginId="iitc-plugin-route-planner@odrick";var e=null,t=[],r=[],o=!1,i={},a=function(n){n.portal.on("click",l)},l=function(n){if(o&&!function(n){for(var e=0;e<t.length;e++){if(t[e].guid===n)return!0}return!1}(n.target.options.guid)){var e={guid:n.target.options.guid,title:n.target.options.data.title,lat:n.target.options.data.latE6/1e6,lng:n.target.options.data.lngE6/1e6};e.title||(e.title=e.lat+", "+e.lng),t.push(e),u(e),s(),c()}},u=function(n){var e=document.createElement("div");e.addEventListener("click",(function(){window.map.setView({lat:n.lat,lng:n.lng},window.map.getZoom())})),e.guid=n.guid,e.className="routePlannerListItem",$(e).append('<div class="routePlannerListItemTitle">'.concat(n.title,"</div>")),$(e).append('<div class="routePlannerListItemControls"><a href="#" onclick="window.plugin.routePlanner.removePoint(\''.concat(n.guid,"')\">X</a></div>")),$("#routePlannerList").append(e)},c=function(){e.clearLayers();for(var n=[],r=0;r<t.length;r++){var o=t[r];L.circleMarker(new L.LatLng(o.lat,o.lng),{color:"#ee6666",opacity:1,weight:5,fill:!0,dashArray:"5, 5",interactive:!1,clickable:!1,radius:14}).addTo(e),n.push(new L.LatLng(o.lat,o.lng))}L.polyline(n,{color:"#ee6666",opacity:1,weight:2,fill:!1,interactive:!1,clickable:!1}).addTo(e),d()},d=function(){r=[];for(var n=[],e=0;e<t.length;e++){var o=t[e];if(0===e&&n.push(""),n.push(o.lat+","+o.lng),10===n.length||e>=t.length-1){var i="https://www.google.com/maps/dir/"+n.join("/");i+="/@"+(n[0]||n[1])+",18z/",r.push(i),n=[n[9]]}}$("#routePlannerLinks").html("");for(var a=0;a<r.length;a++){var l="Navigation";r.length>1&&(l+=a+1);var u='<a href="'+r[a]+'" target="_blank">'+l+"</a>";r.length>1&&a<r.length-1&&(u+=", "),$("#routePlannerLinks").append(u)}};i.removePoint=function(n){for(var e=0;e<t.length;e++){if(t[e].guid===n){t.splice(e,1);for(var r=document.querySelector("#routePlannerList"),o=0;o<r.children.length;o++){var i=r.children[o];i.guid===n&&r.removeChild(i)}return s(),void c()}}},i.showBox=function(){o=!0,$("#routePlannerBox").show()},i.hideBox=function(){o=!1,$("#routePlannerBox").hide()},i.clear=function(){t=[],$("#routePlannerList").html(""),s(),c()},i.export=function(){window.RoutePlannerPluginUtils.downloadFile(JSON.stringify(t),"route-plan.json")},i.import=function(){$("#importInput").click()},i.doImport=function(){var n=$("#importInput").get(0).files[0],e=new FileReader;e.readAsText(n),e.onload=function(){try{var n=JSON.parse(e.result);n&&Array.isArray(n)&&(f(n),s())}catch(n){}},e.onerror=function(){console.log(e.error)}},i.copy=function(){var n=document.createElement("textarea");n.value=r.join("\n\n"),n.style.position="fixed",document.body.appendChild(n),n.focus(),n.select();try{if(document.execCommand("copy")){var e=document.createElement("div");e.innerHTML="Navigation copied",document.body.appendChild(e),e.style.position="fixed",e.style.display="block",e.style.left="50%",e.style.top="50%",e.style.transform="translate(-50%, -50%)",e.style.zIndex=100500,e.style.padding="4px",e.style.background="#fff",e.style.color="#000",setTimeout((function(){document.body.removeChild(e)}),1e3)}}catch(n){}document.body.removeChild(n)};var p=function(n,e){for(var r=e.item[0].guid,o=-1,i=0;i<t.length;i++){t[i].guid===r&&(o=i)}var a=e.item.index();if(o>=0){if(a===o)return;var l=t[o];t.splice(o,1),t.splice(a,0,l)}s(),c()},s=function(){localStorage.setItem("iitc-plugin-route-planner",JSON.stringify(t))},f=function(n){t=n;for(var e=0;e<t.length;e++)u(t[e]);c()};function g(){$("<style>").prop("type","text/css").html(window.RoutePlannerPluginUtils.css).appendTo("head"),$("body").append(window.RoutePlannerPluginUtils.ui),$("#routePlannerBox").draggable({handle:".handle",containment:"window"}),$("#routePlannerList").sortable({update:p}),$("#toolbox").append('<a onclick="window.plugin.routePlanner.showBox();return false;">Route planner</a>'),e=new L.LayerGroup,window.addLayerGroup("Route planner",e,!1),window.addHook("portalAdded",a),function(){var n=localStorage.getItem("iitc-plugin-route-planner");if(n)try{f(JSON.parse(n))}catch(n){t=[]}}(),c()}window.plugin.routePlanner=i,g.info=n,window.bootPlugins||(window.bootPlugins=[]),window.bootPlugins.push(g),window.iitcLoaded&&g()}+")("+JSON.stringify(s)+")");p.appendChild(f),(document.body||document.head||document.documentElement).appendChild(p)}]);