Skip to content

Instantly share code, notes, and snippets.

@eddiemoya
Forked from svebal/iitc-export-import-draw.js
Created February 2, 2016 21:18
Show Gist options
  • Save eddiemoya/a2e5e2967cdd6285a4d6 to your computer and use it in GitHub Desktop.
Save eddiemoya/a2e5e2967cdd6285a4d6 to your computer and use it in GitHub Desktop.
Plugin for IITC - let you im- / export your sketches from drawing tools
// ==UserScript==
// @id iitc-export-import-draw@skamander
// @name IITC plugin: export and import data from draw tools
// @version 0.0.1
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @description Import/Export Data from draw tools
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
// 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
var thisplugin = window.plugin.drawtools_export = function() {};
// function to import
window.plugin.drawtools_export.import_drawdata = function() {
localStorage['plugin-draw-tools-layer'] = prompt('Bitte geben sie die Daten ein:');
window.location.reload()
}
// funcion to export
window.plugin.drawtools_export.export_drawdata = function() {
prompt("Copy to clipboard: Ctrl+C, Enter", localStorage['plugin-draw-tools-layer']);
}
// ===[ Settings ]=====================================================================================
var setup = function () {
content = "<a onclick='window.plugin.drawtools_export.import_drawdata();' >Import draw-data</a>"
content += "<a onclick='window.plugin.drawtools_export.export_drawdata();' >Export draw-data</a>"
$('#toolbox').append(content);
}
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins) {
window.bootPlugins.push(setup);
} else {
window.bootPlugins = [setup];
}
}
} // wrapper end
// inject code into site context
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();'));
(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