// ==UserScript== // @name Kongregate Portal Report // @namespace tag://kongregate.com // @description Find out who has the portals you need // @include http://www.kongregate.com/games/* // @version 0.0.1.20160306135333 // @downloadURL https://update.greasyfork.icu/scripts/17775/Kongregate%20Portal%20Report.user.js // @updateURL https://update.greasyfork.icu/scripts/17775/Kongregate%20Portal%20Report.meta.js // ==/UserScript== try{ if(unsafeWindow && unsafeWindow.holodeck){ dom = unsafeWindow; } else { dom = this; } }catch(e){ dom = this; } if (window.undefined === unsafeWindow.console) { console = new function() { this.log = function(message){}; this.info = function(message){}; this.warn = function(message){}; this.error = function(message){}; }; } else { console = unsafeWindow.console; } var KPRVersion = 0.01; function init_portalReport(){ // If no version of the script is running, write down this one if (!window.KPRMaxVersion) { window.KPRMaxVersion = KPRVersion; setTimeout(init_portalReport, 1000); } // If the max version is less than this version, kill it else if (window.KPRMaxVersion < KPRVersion) { window.KPRMaxVersion = KPRVersion; setTimeout(init_portalReport, 1000); } // If this version is less than the max, kill this one else if (window.KPRMaxVersion > KPRVersion) { console.warn("KPR: Version " + KPRVersion + " is still installed, but is older than another version installed"); return; } // If no version of the script is running, this one is if (!window.KPRScriptRunning) { window.KPRScriptRunning = true; } // If a version of the script is already running, kill this one. else { if (KPRVersion == window.KPRMaxVersion) { // TODO: Is a dupe of the script running on the frame of the game, also? console.warn("KPR: Another instance of Version " + KPRVersion + " attempted to run, but was cancelled."); } else { console.warn("KPR: Version " + KPRVersion + " failed to run because Version " + window.KPRMaxVersion + " was already running."); } return; } console.info("KPR: Kongregate Portal Report loaded! v" + KPRVersion); GM_registerMenuCommand("Run Portal Report", portalReport); dom.holodeck.addChatCommand("portals", portalReport); } window.setTimeout(init_portalReport,0); function portalReport() { if (!dom.holodeck) { // console.log("no holodeck"); window.setTimeout(portalReport, 1000); return; } if (! dom.holodeck._chat_window) { // console.log("no chat window"); window.setTimeout(portalReport, 1000); return; } if (! dom.holodeck._chat_window._active_room) { // console.log("no active room"); window.setTimeout(portalReport, 1000); return; } if (! dom.holodeck._chat_window._active_room._users) { // console.log("no users"); window.setTimeout(portalReport, 1000); return; } var users = dom.holodeck._chat_window._active_room._users; var groupMap = {"atlas":[],"p-body":[]}; for (var username in users) { var user = users[username]; if (user) { var group = user.variables.dueling_group; if (group) { var need = user.variables.portals_needed; var has = user.variables.portals_to_give; groupMap[group][username] = {"name":username,"need":need, "has":has}; } } } var reportString = ""; var currentUser = dom.holodeck._active_user._attributes._object; var userGroup = currentUser.dueling_group; var iNeed = currentUser.portals_needed; var iHave = currentUser.portals_to_give; if (userGroup) { reportString += "