Add jQuery to almost any site from the console in your browser

First I must stress that I’m copying this article from here. I’m writing this post so I can keep this snippit of code in a place that’s handy. As I say I read this artice on SpYk3’s blog and all credit must go to him.

If you have a modern browser you’ll be able to find the console, The Firebug extension in Firefox is the easiest way to do this. Open the console and paste these lines of code in:

if(typeof jQuery === 'undefined') {
  var $script = document.createElement("script");
	$script.src = "http://code.jquery.com/jquery-1.9.1.min.js";
	$script.type = "text/javascript";
	document.getElementsByTagName('head')[0].appendChild($script);
}

You should now be able to use jQuery and run any commands you wish. All this code is doing is adding a script tag to the webpage and adding it to the <head> tag that exists in nearly every webpage. The source attribute of the script tag loads the jQuery javascript from the URL it’s specified.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s