Show Delicious Images

By claytron Last update Jan 17, 2009 — Installed 300 times. Daily Installs: 0, 0, 0, 0, 1, 1, 0, 0, 2, 1, 0, 0, 4, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0

There are 6 previous versions of this script.

// ==UserScript==
// @name           Show Delicious Images
// @namespace      http://claytron.com/gmscripts/
// @description    Show images inline in delicious
// @include        http://delicious.com/*
// ==/UserScript==
//
// I totally ripped off some of this code from somewhere as an 
// example, but now I don't remember where :(  So to whoever it
// was, Thanks....and sorry.
//
// For an example, go here:
// http://delicious.com/claytron/funny+system:media:image

(function(){

function init() {
    var tags = document.getElementsByTagName('h4');
    re = /\.(jpg|jpeg|png|gif)$/i;
    // make sure not to get the same image multiple times
    var shown = new Array();
    for (i = 0; i < tags.length; i++) {
        var link_tag = tags[i].childNodes[1];
        var link_href = link_tag.href;
        if (re.test(link_href)) {
            if (shown.indexOf(link_href) == -1) {
                shown[i] = link_href;
                add_thumbnail(link_tag);
            };
        };
    };
}

function add_thumbnail(link) {
    var thumb = document.createElement('img');
    thumb.src = link;
    thumb.style.maxWidth = "883px";
    thumb.style.display = "block";
    thumb.style.margin = "8px 0";
    link.parentNode.insertBefore(thumb, link.nextSibling());
}

init();

}());