Skip to content

Instantly share code, notes, and snippets.

@iqbalrony
Last active June 19, 2019 07:51
Show Gist options
  • Save iqbalrony/e889bb0eb005301805355da2d32b008c to your computer and use it in GitHub Desktop.
Save iqbalrony/e889bb0eb005301805355da2d32b008c to your computer and use it in GitHub Desktop.
/**
* To externally insert jQuery on that webpage from your browser’s console
* all you need to do is to copy-paste and run the following code in the console.
*/
var script = document.createElement("script");
script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
/**
* Better way for regular users: creating a Bookmark makes it really convenient.
* Follow the steps below to create a bookmark.
* 1:- Right click the Bookmarks Bar, and click Add Page
* 2:- Name it as you like, e.g. Inject jQuery, and use the following code line for URL.
*/
//URL
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
//URL (to get the latest js version)
javascript:if(!window.jQuery||confirm('Overwrite\x20current\x20version?\x20v'+jQuery.fn.jquery))(function(d,s){s=d.createElement('script');s.src='http://code.jquery.com/jquery.js';(d.head||d.documentElement).appendChild(s)})(document);
//Above code has been tested on google chrome and firefox browser.
//For break a line in console panel press shift+enter.
//Enjoy consoling and play with js :)
//Idea get from following post:
//https://stackoverflow.com/questions/3821703/testing-jquery-statements-in-chrome-javascript-console
//https://stackoverflow.com/questions/9624972/command-for-loading-jquery-on-google-chrome-inspector/9624997#9624997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment