Skip to content

Instantly share code, notes, and snippets.

@printminion
Last active June 2, 2022 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save printminion/4141199 to your computer and use it in GitHub Desktop.
Save printminion/4141199 to your computer and use it in GitHub Desktop.
Inject jQuery via console to the site
/**
* @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')});
@nyinker
Copy link

nyinker commented Jun 2, 2022

How does things get added to the adapters array...? Shouldn't it be a part of on 'load'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment