This is a JavaScript bookmarklet to display a link to a user's del.icio.us bookmarks using the autodiscovery
technique developed for syndication feeds.
<link rel = "alternate" type = "text/html" title = "delicious links" href = "http://del.icio.us/straup" />
Drag this
link to your bookmarks tab — or click to see it in action. If a webpage contains a <link>
element whose type
attribute is text/html
and whose title
attribute is delicious links
then the bookmarklet will draw a new block element containing a link to the value of the href
attribute.
var res = null; var ok_title = new RegExp("^del\.?icio\.?us links"); var ok_type = "text/html"; var content_txt = "This person's del.icio.us links can be seen at "; // set up a wrapper element (res) because the magic // DOM-CSS stuff doesn't seem to do the right thing // with margins var res_css = "padding-bottom:15px;"; var content_css = "margin-bottom:10px;border:1px solid #ccc; padding:5px;background-color:beige;"; var doc = document; var list = doc.getElementsByTagName("link"); for (var i = 0; i < list.length; i++) { var link = list[i]; if ((link.type == ok_type) && (ok_title.test(link.title))) { var regexp_del = new RegExp("^(http:\/\/del\.icio\.us)\/(.*)$"); var url_rss = link.href.replace(regexp_del,"$1/rss/$2"); var html = doc.createElement("a"); html.setAttribute("href",link.href); html.appendChild(doc.createTextNode(link.href)); var rss = doc.createElement("a"); rss.setAttribute("href",url_rss); res = doc.createElement("div"); res.setAttribute("style","padding-bottom:15px"); content = doc.createElement("div"); content.setAttribute("style",content_css); content.appendChild(doc.createTextNode("rss")); content.appendChild(doc.createTextNode(res_txt)); content.appendChild(html); content.appendChild(doc.createTextNode(" (")); content.appendChild(rss); content.appendChild(doc.createTextNode(")")); res.appendChild(content); break; } } if (res) { void(doc.body.insertBefore(res,doc.body.firstChild)); } else { alert("no del.icio.us links"); }