Last active
November 6, 2020 10:39
-
-
Save johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31 to your computer and use it in GitHub Desktop.
This file contains 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 debug-console-re | |
// @name IITC plugin: Console.Re | |
// @description Remote console: http://console.re/ | |
// @category Debug | |
// @version 0.1 | |
// @author jd | |
// @namespace https://gist.github.com/johnd0e | |
// @homepageURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31 | |
// @supportURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31#new_comment_field | |
// @downloadURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31/raw/debug-console-re.user.js | |
// @match https://intel.ingress.com/* | |
// @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 //////////////////////////////////////////////////////// | |
function inject (channel) { | |
let script = document.createElement('script'); | |
script.src='https://console.re/connector.js'; | |
script.id = 'consolerescript'; | |
script.dataset.channel = channel; | |
script.onload = function() { this.remove(); }; | |
script.onerror = function() { alert('Error loading: ' + this.src); }; | |
document.body.appendChild(script); | |
} | |
function setup () { | |
$('<a title="Remote JavaScript Development Console">Console.Re</a>') | |
.appendTo($('#toolbox')) | |
.click(function (e) { | |
inject('iitc-ce'); | |
$(e.target) | |
.css('color','darkgray') | |
.off('click'); | |
}); | |
} | |
// 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); |
This file contains 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 debug-remotejs | |
// @name IITC plugin: RemoteJS | |
// @description Remote JavaScript Debugging | |
// @category Debug | |
// @version 0.1 | |
// @author jd | |
// @namespace https://gist.github.com/johnd0e | |
// @homepageURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31 | |
// @supportURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31#new_comment_field | |
// @downloadURL https://gist.github.com/johnd0e/a7dc7f33f0970a2f2b00a63f1046fd31/raw/debug-remotejs.user.js | |
// @match https://intel.ingress.com/* | |
// @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 //////////////////////////////////////////////////////// | |
function reload () { | |
if (typeof android !== 'undefined' && android.reloadIITC) { | |
android.reloadIITC(); | |
} else { | |
window.location.reload(); | |
} | |
} | |
function inject (channel) { | |
var script = document.createElement('script'); | |
script.src='https://remotejs.com/agent/agent.js'; | |
script.dataset.consolejsChannel = channel; | |
script.onload = function() { this.remove(); }; | |
script.onerror = function() { alert('Error loading: ' + this.src); }; | |
document.body.appendChild(script); | |
} | |
var channel = sessionStorage.remoteJs; | |
if (channel) { | |
inject (channel); | |
} | |
function getChannelName () { | |
return localStorage.remoteJs || 'iitc-ce'; | |
} | |
var link; | |
function changeChannel () { | |
var initial = channel || getChannelName(); | |
var newchannel = prompt('Change RemoteJS channel', initial); | |
if (newchannel !== null) { | |
localStorage.remoteJs = newchannel; | |
channel = getChannelName(); | |
if (channel === initial) { return false; } | |
if (link.hasClass('remotejs-active')) { | |
if (confirm('Reload IITC?')) { reload(); } | |
} else { | |
link.click(); | |
} | |
} | |
return false; | |
} | |
function setup () { | |
$('<style>') | |
.html('a.remotejs-active {color: darkgray; text-shadow: 0 0 10px white;}') | |
.appendTo(document.head); | |
link = $('<a>').html('RemoteJS') | |
.attr({ | |
title: 'Remote JavaScript Debugging', | |
class: channel && 'remotejs-active' | |
}) | |
.click(function () { | |
if (link.hasClass('remotejs-active')) { | |
delete sessionStorage.remoteJs; | |
link.remove(); | |
if (confirm('Reload IITC?')) { reload(); } | |
} else { | |
channel = getChannelName(); | |
inject(channel); | |
sessionStorage.remoteJs = channel; | |
link.addClass('remotejs-active'); | |
} | |
}) | |
.on('contextmenu', changeChannel) | |
.appendTo('#toolbox'); | |
} | |
// 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