Quantcast
Channel: Phil Lavin’s Articles at Phil’s Blog
Viewing all articles
Browse latest Browse all 79

Injecting jQuery into a web site

$
0
0

This is really useful if you need to hack around with a site that doesn’t use jQuery. In my case, the web interface of a crappy Chinese IP camera which did its recording scheduling by making you click every 15 minute block in the week that you want to record.

Full credit should be given to http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet.

Code which you can put into your browser’s debugging console is as follows:

  1. (function getScript(url){
  2. var script=document.createElement('script');
  3. script.src=url;
  4.  
  5. var head=document.getElementsByTagName('head')[0],
  6. done=false;
  7.  
  8. // Attach handlers for all browsers
  9. script.onload=script.onreadystatechange = function() {
  10. if ( !done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete') ) {
  11. done=true;
  12.  
  13. script.onload = script.onreadystatechange = null;
  14. head.removeChild(script);
  15. }
  16. };
  17.  
  18. head.appendChild(script);
  19. })('http://code.jquery.com/jquery.min.js');

Viewing all articles
Browse latest Browse all 79

Trending Articles