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,Images of '"+document.title+"' ";
doc += "Images of "+document.title+"
";
seen = {};
for(var i = 0; i < document.links.length; i++) {
link = document.links[i].href;
if (link.match(regex) && !seen[link]) {
doc += "
\n";
doc += ""+link+"";
seen[link] = 1;
}
}
doc += "\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).