Last active
January 26, 2017 02:31
-
-
Save red-murphy/2ba29058f7178d214b41faf6123483bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @id iitc-barcode-decoder@nerd4lyfe | |
| // @name IITC plugin: Replace player names with more easily remembered names | |
| // @category Misc | |
| // @version 0.0.1.20170125183000 | |
| // @namespace https://github.com/jonatkins/ingress-intel-total-conversion | |
| // @description [2017-01-24-165600] Click on barcode names to convert them to something you can remember | |
| // @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.barcodes = function() {}; | |
| // Map of known ENL agentsDD | |
| window.plugin.barcodes.nameMap = { | |
| "IllllllllllllI": "cookiesI12", | |
| "llllIIIIllllIII": "M0THERF0CKER", | |
| "lllIIllIIllIIIl": "BaronVizkopa", | |
| "IIllIlIlIIlIIll": "SmurfStalkin", | |
| "IlIlIlIlIlIlllI": "BK2OI", | |
| "IllIIIllIIIIlII": "Krapos", | |
| "lIIllIIllIlIIlI": "Soulweeper", | |
| "IIIlIIIlllIIlII": "Heisenturd", | |
| "IIllIllIllIllI": "ProgrumUrrhurr", | |
| "IlIIIlIIlIIllll": "midnight1994", | |
| "lIIlIllIIIIllIl": "gotmystogan", | |
| "lIIIIIlIIlIIIIl": "akio", | |
| "llIlIIIlIlIlllI": "Harooukin", | |
| "IlllIIIIIllIlII": "catwoman", | |
| "IIllIIlIIllIllI": "FiverOhFive", | |
| "IllIIIIllIlIIll": "LIFS", | |
| "lIIlllIllIIIIIl": "hammer", | |
| "IIlllIllIlIIllI": "play333", | |
| "lIlIIlIllIlIIll": "tvvsmom", | |
| "IIIllIllIllIllI": "227ths", | |
| "lIIllIlllIIIllI": "coldpizzarolls", | |
| "IlIlIIllIlIllll": "tvvsdad", | |
| "lIIlIllIlIIIlll": "nothingtheir", | |
| "IlllIlIIllIlIlI": "ab554", | |
| "IllIlllllll": "mistercee47" | |
| }; | |
| window.plugin.barcodes.barPatt = new RegExp("^[Il]{8,15}$"); | |
| /* | |
| window.chat.nicknameClicked = function(event, nickname) { | |
| var hookData = { event: event, nickname: nickname }; | |
| if (window.runHooks('nicknameClicked', hookData)) { | |
| if (window.plugin.barcodes.decode(nickname) !== nickname) { | |
| window.chat.addNickname('@' + nickname + " (" + window.plugin.barcodes.decode(nickname) + ")"); | |
| } | |
| else { | |
| window.chat.addNickname('@' + nickname); | |
| } | |
| } | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| return false; | |
| } | |
| */ | |
| window.plugin.barcodes.replaceNames = function(data) { | |
| var barPatt = window.plugin.barcodes.barPatt; | |
| console.log(this); | |
| $(".nickname, .pl_nudge_player").each(function(index, value){ | |
| value = $(value); | |
| var nickname = value.text(); | |
| if (barPatt.test(nickname)) nickname = window.plugin.barcodes.decode(nickname); | |
| value.text(nickname); | |
| }); | |
| $(".pl_nudge_player").each(function(index, value){ | |
| value = $(value); | |
| var nickname = value.text(); | |
| nickname = nickname.substring(1,nickname.length); | |
| if (barPatt.test(nickname)) nickname = window.plugin.barcodes.decode(nickname); | |
| value.text("@" + nickname); | |
| }); | |
| }; | |
| window.plugin.barcodes.decode = function(barcode) { | |
| console.log("barcode", barcode); | |
| if (barcode in window.plugin.barcodes.nameMap){ | |
| return window.plugin.barcodes.nameMap[barcode]; | |
| } | |
| else { | |
| var s = ""; | |
| for (i=0;i<3;i++){ | |
| var b = barcode.slice((5*(i+1))-5,5*(i+1)).replace(/\I/g,'0').replace(/\l/g,'1'); | |
| var d = parseInt(b, 2); | |
| s += String.fromCharCode(64 + d); | |
| } | |
| if (s.length === 3) return s; | |
| else return barcode; | |
| } | |
| }; | |
| var setup = function() { | |
| window.addHook('nicknameClicked', window.plugin.barcodes.replaceNames); | |
| }; | |
| // 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