Last active
June 2, 2022 15:08
-
-
Save printminion/4141199 to your computer and use it in GitHub Desktop.
Inject jQuery via console to the site
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
/** | |
* @desc Inject jQuery via console to the site (I found this snippet) | |
* @author Misha M.-Kupriyanov https://plus.google.com/104512463398531242371/ | |
* @link https://gist.github.com/4141199 | |
*/ | |
Scripts = new function() { | |
this.adapters = new Array() | |
}; | |
Scripts.injectScript = function(src, callback) { | |
// If it's already loaded, don't load it again | |
if (Scripts.adapters[src]) { | |
callback(); | |
return; | |
} | |
var head = document.querySelector('head'); | |
var script = document.createElement('script'); | |
script.type = 'text/javascript'; | |
script.src = src; | |
script.addEventListener('load', function() { | |
callback(); | |
}); | |
head.appendChild(script); | |
}; | |
Scripts.injectScript('//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function() { console.log('jquery injected')}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How does things get added to the adapters array...? Shouldn't it be a part of on 'load'?