July 22, 2011

Be a god among internet users

EDIT: Bug fixed, now also works in firefox.

So many times i inject jQuery on a site to do something inside it. Here is a bookmarklet i use a lot: View it on pastebin; so basically why it does is inject jQuery (if is not already on the page) and take care about $.noConflict and all that jazz.

Drag this to your bookmarks: jQuery with prompt (or just click it to test it)

But it also brings a nice prompt in which to write the javascript code (eval is NOT evil!); and it also have some little nice features, you can open the prompt with Shift+J or by clicking the bookmarklet again. It remembers the last code you wrote on it. It also haves a handy function called print, it basically works as a wrapper for document.write javascript function. It also handle any errors in your syntax and you can use the function "$" instead of "jQuery" without breaking anything in the current web site.

So, lets see what this baby can do:

If you need to get the list of you are listening in Grooveshark, you could write this:
$(".songName").each(function(){print($(this).html())})

If you need to select all your friends in Facebook when you create an event...
$(".checkbox").click()

If you need to get all URL addresses from a Google search
$("cite").each(function(){print(this.innerHTML)})

To archive all your facebook messages (well, just current page)
$("#MessagingDashboard .archiveLink input").click();


Scrapping FUN!


Everyone loves to scrapp; so lets do that (ab)using Ajax! This code gets all links of the first 9 pages of a Google search result.

window.arrxx=[];$("#navcnt .fl").each(function(i){var opq = i;var that=this;setTimeout(function(){ $.get(that.href,function(data){ $("<div"+">").html(data).find("cite").each(function(){arrxx.push("http://"+$(this).text()) });if(opq == $("#navcnt .fl").length - 1){document.write("<pre"+">"+arrxx.join("\n")+"</p"+"re>")}})},1000*(i+1))});

5 comments:

  1. this doesn't seem work for me. what OS and browser are you using?

    ReplyDelete
  2. I am so sorry... It doesnt seem to work properly on Firefox.

    I am using Google Chrome on Windows 7 (it works on IE9 too).

    Tomorrow i will fix this incompatibility with firefox.

    ReplyDelete
  3. Confirmed and working in win7 on ff 5.0.

    Awesome scripting and thx

    ReplyDelete
  4. thank you for the weblog stuffed while for that reason many records. stopping by your blog helped me to make a get hold of of what i was searching out. Now my challenge has come to be as easy as ABC. internet providers toronto

    ReplyDelete
  5. That is really nice to hear. thank you for the update and good luck. personvernpanettet

    ReplyDelete

You can use [CODE][/CODE] to post Javascript code.
You can start a sentence with ">" to make a quotation.