Skip to content

Instantly share code, notes, and snippets.

@appastair
Last active August 16, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appastair/2a15cc369049720178a8e36eadfba90b to your computer and use it in GitHub Desktop.
Save appastair/2a15cc369049720178a8e36eadfba90b to your computer and use it in GitHub Desktop.
Automated importer of unique portals captured for use with the IITC Uniques plugin.
// ==UserScript==
// @id iitc-plugin-uniques-importer@Appastair
// @name IITC plugin: Uniques Importer
// @category Misc
// @version 0.1.3.20180809.147
// @namespace https://gist.github.com/appastair/2a15cc369049720178a8e36eadfba90b
// @updateURL https://gist.github.com/appastair/2a15cc369049720178a8e36eadfba90b
// @downloadURL https://gist.github.com/appastair/2a15cc369049720178a8e36eadfba90b
// @description Automated importer of unique portals captured for use with the Uniques plugin.
// @include https://*.ingress.com/intel*
// @include http://*.ingress.com/intel*
// @match https://*.ingress.com/intel*
// @match http://*.ingress.com/intel*
// @include https://*.OMINOUSLY.MISSING/*
// @match https://*.OMINOUSLY.MISSING/*
// @include https://*.ingress.com/mission/*
// @include http://*.ingress.com/mission/*
// @match https://*.ingress.com/mission/*
// @match http://*.ingress.com/mission/*
// @run-at document-ready
// @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 ////////////////////////////////////////////////////////
var setup = function(){
var dataDomain = 'OMINOUSLY.MISSING';
if(dataDomain === 'OMINOUSLY'+'.'+'MISSING'){
window.dialog({
title: 'Unique Data Domain',
html: "<p>Please update the <b>IITC plugin: Uniques Importer</b> script and change:</p>"+
"<ol><li><b>"+dataDomain+"</b> on Line 33 to your data source.</li>"+
"<li>The <i>include</i> and <i>match</i> domains on line 13 and 14.</li></ol>"+
"<p>Alternatively, run <b>Find & Replace</b> <code>"+dataDomain+"</code> with <code>datadomain.xyz</code>in a text 3d1t0r.</p>"
});
}else if(typeof(window.plugin.uniques) === 'undefined'){
console.warn('IITC "Uniques" Plugin Required: https://static.iitc.me/build/release/plugins/uniques.user.js');
}else{
jQuery.get('https://api.'+dataDomain+'/intel/uniques/'+PLAYER.nickname).done(function(uniqueCaptures){
Object.keys(uniqueCaptures).forEach(function(guid){
window.plugin.uniques.uniques[guid] = jQuery.extend(true,window.plugin.uniques.uniques[guid],{captured:true,visited:true});
});
window.plugin.uniques.sync();
if(window.plugin.uniques.highlighter.highlight){
changePortalHighlights('No Highlights');
}
changePortalHighlights('Uniques');
updatePortalHighlighterControl();
console.table({'Unique Captures Imported':Object.keys(uniqueCaptures).length});
window.dialog({
title: 'Uniques',
html: "<p>Unique Captures Imported: "+
"<strong class='res'>"+Object.keys(uniqueCaptures).length+"</strong></p>"
});
});
}
};
// 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);
@appastair
Copy link
Author

Example of expected data format:

{
"001883a1f40f42eb8e749e237b222427.16": "0",
"0021c0a1df0b40a5bcb12dbfe5e87114.11": "1"
}

"GUID", "flipped index"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment