inJsect - Remote script luncher
Creates a GUI for injecting external javascript files to the page you are viewing.
by m0sa
HTML
<div>Some content...</div>
JavaScript
/**
* inJsect.js by m0sa
*/
(function() {
var div = document.createElement('div');
div.style.position = 'absolute';
div.style.zIndex = '99999';
div.style.left = div.style.top = '10px';
div.style.backgroundColor = 'white';
div.style.border = 'solid 1px red';
div.innerHTML = '<table><tr><td>Script:</td><td><input type="text" value="http://" id="runRemoteUrl" style="width: 250px" /></td><td><input type="button" value="Run" id="runRemote" /></td></tr><tr><td>Remove:</td><td colspan="2"><input style="width: 250px" type="text" value="" id="removeUrl" /></td></tr><tr><td colspan="3">Execute on load:</td></tr><tr><td colspan="3"><textarea id="onLoad" style="width: 400px; height: 150px"></textarea></td></tr></table>';
document.body.appendChild(div);
document.getElementById('runRemote').onmousedown = function() {
var val = document.getElementById('runRemoteUrl').value,
rem = document.getElementById('removeUrl');
if (rem) {
var scripts = document.getElementsByTagName('script') || [],
i = 0;
for (i in scripts) {
if (scripts[i].src == rem) {
scripts[i].parentNode.removeChild(scripts[i]);
}
}
}
if (val) {
var fired = false,
evalScript = document.getElementById('onLoad').value,
script = document.createElement('script'),
target = document.getElementsByTagName('head')[0] || document.body;
document.body.removeChild(div);
script.src = val;
script.onreadystatechange = function() {
if (evalScript && !fired && this.readyState == 'complete') {
eval(evalScript);
fired = true;
}
};
script.onload = function() {
if (evalScript && !fired) {
eval(evalScript);
...