Skip to content

Instantly share code, notes, and snippets.

@ozero
Created August 15, 2015 13:26
Show Gist options
  • Save ozero/e8c5a324438a159f6c53 to your computer and use it in GitHub Desktop.
Save ozero/e8c5a324438a159f6c53 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @id iitc-plugin-rgfx-dumpcomm@rgfx
// @name IITC plugin : Dump comm
// @category Tweaks
// @version 0.0.1.20150810.000000
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL
// @downloadURL
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @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 ////////////////////////////////////////////////////////
window.plugin.dumpcomm = function() {};
window.plugin.dumpcomm.processed = {};
window.plugin.dumpcomm.handleData = function(data) {
data.raw.result.forEach(function(item) {
var guid = item[0];
var time = item[1];
var plext = item[2].plext;
console.log("■DUMPCOMM");
console.log(item);
// ignore early messages
if ((Date.now() - time) > 10 * 60 * 1000) {
return;
}
// ignore non broadcast messages
if (plext.plextType !== "SYSTEM_BROADCAST") {
return;
}
});
};
var setup = function() {
addHook('publicChatDataAvailable', window.plugin.dumpcomm.handleData);
};
// PLUGIN END //////////////////////////////////////////////////////b///
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