Bookmarklet Link Extractor

For a while I was wondering how could I write a button like google bookmark. Few days ago I came to know this technology’s name is bookmarklet. The word bookmarklet came from bookmark + applet, is just a bookmark having a javascript function in its URL. Javascript function in URL is possible, as modern browser supports javascript: prefix like http:, ftp:, or https:. It offers a lot of advanced feature in browsing. Wikipedia have good details, take a look, BOOKMARKLET on Wikipedia.

Then i gave a try to write one. this typical bookmarklet firstly ask for few predefined options then extract all the link of matching types. And options are optimized for google filetype : *** search result.

To use copy following lines and then create a bookmark with this text in url.

javascript:w=open('','linkextractor','scrollbars,resizable,menubar');d=document.links;p=prompt('Enter number form bellow list: \n1 \.pdf but not contain google.com \n2 .ppt but not contain google.com\nOr Enter file type without * and . ie svg \nOr Simply keep empty for all links','');var nreg=new RegExp(%22google.com%22);with(w.document){if(p==1){var fileType=%22\.pdf$%22;}else if (p==2){var fileType=%22\.ppt$%22;}else if (p== null || p==%22%22){var fileType=%22.*%22;}else{var fileType=%22\.%22 + p + %22$%22;}var reg=new RegExp(fileType);for(i=0;i<d.length;i++){var s =d[i].toString();if(reg.test(s) == true &&  nreg.test(s) == false ){write(document.links[i].toString() +'<br/>\n');}};void(close());}

How to use:

Firstly search in google using filetype: option (say filetype:pdf binary heap)
the click this bookmark.

will see a prompt, choose a number or type the filetype or left empty to list all.

Google Search Result Extractor

another window will open, with the list of links. copy it or save it in plain text format use wget or any download manager you like, grab the files.

NB: this is my first bookmarklet, could face error, let me know. And have some idea to develop it.

Advertisements

One thought on “Bookmarklet Link Extractor

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