bookmarklet_--_open_all_image_links
Bookmarklets are cool. They're javascript in a bookmark form, and they look like this:
javascript:(function(){ //code })();
You can read or modify the current page by referring to document
. Here's one that opens a new tab with all image links from a page:
javascript:(function(){ /* This regex was adapted from the BrowseImages extension for Firefox. */ var regex= new RegExp('(\\.jpg$|\\.jpg[&;])|(\\.gif$|\\.gif[&;])|(\\.png$|\\.png[&;])|(\\.jpeg$|\\.jpeg[&;])|(\\.bmp$|\\.bmp[&;])|(\\.svg$|\\.svg[&;])|(\\/full\\.php\\?.*ima?ge?=)|(\\/preview\\.php\\?.*ima?ge?=)|(\\/view\\.php\\?.*ima?ge?=)|(\\/view\\.php\\?.*pic=)|(\\/view\\.showImage\\.php)|(album_pic\\.php?pic_id=)|(\\dchan\\.org\\/.*\\/cb-nws\\/)|(\\dchan\\.org\\/.*src\\.cgi)|(attachment\\.php\\?attachmentid=\\d+&d=\\d+)', "i"); var doc = "data:text/html,<html><head><title>Images of '"+document.title+"'</title></head>"; doc += "<body style='text-align:center; font-family: Verdana, sans-serif; font-size:80%;'><H1>Images of <a href='"+document.URL+"'>"+document.title+"</a></h1>"; seen = {}; for(var i = 0; i < document.links.length; i++) { link = document.links[i].href; if (link.match(regex) && !seen[link]) { doc += "<img src='"+link+"'><br>\n"; doc += "<a href='"+link+"'>"+link+"</a><p>"; seen[link] = 1; } } doc += "</body></html>\n"; open(doc); })();
You can install a new bookmarklet from scratch by copying the code in question, creating a new bookmark, and pasting the content into the location field (Firefox will take care of newlines and other issues automatically). You can give them out just by making a link (but you'll have to escape a bunch of stuff, and I never bothered with that).
bookmarklet_--_open_all_image_links.txt · Last modified: 2011/04/24 21:56 by tkbletsc