Created
June 8, 2017 01:19
-
-
Save Asbra/a507cf4003ed91a19ada95b813730a9c to your computer and use it in GitHub Desktop.
Anti-Adblock JavaScript loader
This file contains hidden or 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
(function() { | |
var index = 0, | |
scripts = ["https://domain.tld/script1.js","https://otherdomain.tld/script2.js"], | |
newScriptNode, | |
loadScripts = function () { | |
if (index >= scripts.length) { return; } | |
newScriptNode = window.document.createElement("script"); | |
newScriptNode.type = "text/javascript"; | |
newScriptNode.async = true; | |
var scriptNode = window.document.getElementsByTagName("script")[0]; | |
newScriptNode.src = scripts[index]; | |
// newScriptNode.crossOrigin = "anonymous"; | |
newScriptNode.onerror = function () { | |
index++; | |
loadScripts() | |
}; | |
scriptNode.parentNode.insertBefore(newScriptNode, scriptNode) | |
}; | |
loadScripts(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment