Created
August 31, 2015 12:57
-
-
Save AdamSaleh/0615769ffc120660a381 to your computer and use it in GitHub Desktop.
Testing javascript injection
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
var jqueryInjector = function(callback) { | |
jqueryUrl = 'https://code.jquery.com/jquery-1.11.3.min.js'; | |
if (typeof jQuery == 'undefined') { | |
var script = document.createElement('script'); | |
var head = document.getElementsByTagName('head')[0]; | |
var done = false; | |
script.onload = script.onreadystatechange = (function() { | |
if (!done && | |
(!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { | |
done = true; | |
script.onload = script.onreadystatechange = null; | |
head.removeChild(script); | |
callback(); | |
} | |
}); | |
script.src = jqueryUrl; | |
head.appendChild(script); | |
} else { | |
callback(); | |
} | |
} |
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
Then when you run | |
return this.execute( | |
jqueryInjector, | |
[],cb); | |
You can be sure that you have jQuery aviable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment