I was getting tired of opening a ton of tabs to view images in a gallery so I made a small bookmarklet to handle it for me. This little bit of code will grab all of the unique image links from a page and open them as images in a new window (BMP, JPG, JPEG, PNG, GIF).
View Unique ImagesHere’s the source if you feel inclined to chop it up:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | javascript:(function() { var al = document.links; var ol = new Array(); function in_array(n, h) { var i = h.length; while(i--) { if(h[i] === n) { return true; } } return false; } function gl(a) { for(l in a) { u = a[l].href; if(u !== undefined && u != '') { uq = u.split('?'); if(uq.length > 1) { u = uq[0]; } if(u.search('/.')) { ua = u.split('.'); switch(ua[(ua.length-1)]) { case 'bmp': case 'jpg': case 'jpeg': case 'png': case 'gif': if(!in_array(u, ol)) ol.push(u); break } } } } } function ow(t) { w=window.open(); w.document.write(t); w.focus(); } function s() { gl(al); t = ''; if(ol.length > 0) { for(i in ol) t += '<div style="clear:both;margin:20px auto;width:100%"><img src="'+ol[i]+'" style="height:auto;clear:both;display:block;margin:0 auto;max-width:100%;" /></div><hr />'; ow(t); } else { alert("No suitable image links were found."); } } s(); })() |
Let me know in the comments if you find this bookmarklet useful!
