Created
March 6, 2015 00:37
-
-
Save lqdc/0e943a6a3ad0ca6277e7 to your computer and use it in GitHub Desktop.
jsinject.js
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
<script type="text/javascript"> | |
function loadCustomScripts() { | |
var elems = document.getElementsByTagName('IMG'); | |
console.log(elems); | |
for (var x = 0; x < elems.length; x++) { | |
if (elems[x].className.indexOf("JS_EMBED") >= 0) { | |
var use_source = elems[x].src; | |
if (/^https?:\/\/[^\/\\]+[.]juniper[.]net\/[^?]+[.]js$/.exec(use_source)) { | |
var s = document.createElement('SCRIPT'); | |
s.type = "text/javascript"; | |
s.src = use_source; | |
elems[x].parentNode.insertBefore(s, elems[x]); | |
elems[x].parentNode.removeChild(elems[x]); | |
} | |
else { | |
console.log('Illegal attempt to import a js file from: ' + use_source); | |
} | |
} | |
} | |
} | |
console.log("HI THERE"); | |
if (window.addEventListener) { | |
console.log("AFTER FIRST IF"); | |
window.addEventListener('load', loadCustomScripts, false); | |
} | |
else if (window.attachEvent) { | |
console.log("AFTER ELSE IF"); | |
window.attachEvent('onload', loadCustomScripts); | |
} | |
else{ | |
console.log("AFTER ELSE"); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment