// ==UserScript== // @author Zaso // @name Fake Message Location // @category Misc // @version 0.1.1.20200216.174029 // @description Set a location. The COMM messages you send will have the setted location. // @id fake-message-location@Zaso // @namespace https://github.com/IITC-CE/ingress-intel-total-conversion // @downloadURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/Zaso/fake-message-location.user.js // @updateURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/Zaso/fake-message-location.meta.js // @match https://intel.ingress.com/* // @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 AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! //(leaving them in place might break the 'About IITC' page or break update checks) plugin_info.buildName = 'ZasoItems'; plugin_info.dateTimeVersion = '2020-02-16-174029'; plugin_info.pluginId = 'fake-message-location'; //END PLUGIN AUTHORS NOTE // PLUGIN START //////////////////////////////////////////////////////// // History // 0.1.1 Headers changed. Ready for IITC-CE // 0.1.0 Original sript window.plugin.fakeMsgLoc = {}; window.plugin.fakeMsgLoc.storage = {}; window.plugin.fakeMsgLoc.obj = {}; window.plugin.fakeMsgLoc.data = {}; window.plugin.fakeMsgLoc.getHTML = {}; window.plugin.fakeMsgLoc.dialog = {}; window.plugin.fakeMsgLoc.action = {}; window.plugin.fakeMsgLoc.ui = {}; window.plugin.fakeMsgLoc.override = {}; // ***************************************************************** //----------------------------------- // OBJECT //----------------------------------- window.plugin.fakeMsgLoc.obj.getMainObjDefault = function(){ return {location: null, enabled: false}; } window.plugin.fakeMsgLoc.obj.main = window.plugin.fakeMsgLoc.obj.getMainObjDefault(); //----------------------------------- // STORAGE //----------------------------------- window.plugin.fakeMsgLoc.storage.NAME = 'plugin-fake-message-location'; window.plugin.fakeMsgLoc.storage.save = function(){ window.localStorage[window.plugin.fakeMsgLoc.storage.NAME] = JSON.stringify(window.plugin.fakeMsgLoc.obj.main); } window.plugin.fakeMsgLoc.storage.load = function(){ window.plugin.fakeMsgLoc.obj.main = JSON.parse(window.localStorage[window.plugin.fakeMsgLoc.storage.NAME]); } window.plugin.fakeMsgLoc.storage.reset = function(){ window.plugin.fakeMsgLoc.data.setMainObj(window.plugin.fakeMsgLoc.obj.getMainObjDefault()); window.plugin.fakeMsgLoc.storage.save(); } window.plugin.fakeMsgLoc.storage.delete = function(){ delete window.localStorage[window.plugin.fakeMsgLoc.storage.NAME]; } window.plugin.fakeMsgLoc.storage.check = function(){ if(!window.localStorage[window.plugin.fakeMsgLoc.storage.NAME]){ window.plugin.fakeMsgLoc.storage.reset(); } window.plugin.fakeMsgLoc.storage.load(); } //----------------------------------- // DATA //----------------------------------- window.plugin.fakeMsgLoc.data.setMainObj = function(obj){ window.plugin.fakeMsgLoc.obj.main = obj; } window.plugin.fakeMsgLoc.data.getMainObj = function(){ return window.plugin.fakeMsgLoc.obj.main; } window.plugin.fakeMsgLoc.data.setFakeLoc = function(loc){ var newLoc = null; if(loc instanceof L.LatLng){ newLoc = loc; } window.plugin.fakeMsgLoc.obj.main.location = loc; } window.plugin.fakeMsgLoc.data.getFakeLoc = function(){ try{ var main = window.plugin.fakeMsgLoc.data.getMainObj(); var loc = L.latLng(main.location.lat, main.location.lng); return loc; }catch(e){ return false; } } window.plugin.fakeMsgLoc.data.isEnabledFake = function(){ var main = window.plugin.fakeMsgLoc.data.getMainObj(); if(main.enabled === true){ return true; } return false; } window.plugin.fakeMsgLoc.data.setFakeStatus = function(bool){ var bool = (bool === true)? true : false; window.plugin.fakeMsgLoc.obj.main.enabled = bool; } window.plugin.fakeMsgLoc.data.toggleFakeStatus = function(){ var isEnabledFake = window.plugin.fakeMsgLoc.data.isEnabledFake(); window.plugin.fakeMsgLoc.data.setFakeStatus(!isEnabledFake); return window.plugin.fakeMsgLoc.data.isEnabledFake(); } window.plugin.fakeMsgLoc.data.getCurrLoc = function(){ return window.map.getCenter(); } window.plugin.fakeMsgLoc.data.getLocForMsg = function(){ var isEnabledFake = window.plugin.fakeMsgLoc.data.isEnabledFake(); var currLoc = window.plugin.fakeMsgLoc.data.getCurrLoc(); var fakeLoc = window.plugin.fakeMsgLoc.data.getFakeLoc(); if(isEnabledFake){ if(fakeLoc !== false){ return fakeLoc; } } return currLoc; } window.plugin.fakeMsgLoc.data.getFakePermalink = function(){ var url = 'https://intel.ingress.com/'; var loc = window.plugin.fakeMsgLoc.data.getFakeLoc(); if(loc === false){ return false; } var lat = Math.round(loc.lat*1E6)/1E6; var lng = Math.round(loc.lng*1E6)/1E6; var qry = 'll='+lat+','+lng+'&z='+map.getZoom(); var perma = url+'?'+qry; return perma; } //----------------------------------- // HTML //----------------------------------- window.plugin.fakeMsgLoc.getHTML.toolbox = function(){ var html = ''; var fa = (window.plugin.faIcon)? '' : ''; html += ''+fa+'Fake Msg Loc'; return html; } window.plugin.fakeMsgLoc.getHTML.settings = function(){ var isEnabledFake = window.plugin.fakeMsgLoc.data.isEnabledFake(); var checkStatus = (isEnabledFake)? ' checked ' : ''; var html = ''; html += ''; html += '