Link bookmarklets

Links are one of the most important parts of any web page, yet most browsers provide very few tools to help manage them. And that's where bookmarklets can help.

Highlight links
javascript:for(nIx5Bs=0;nIx5Bs<document.all.length;nIx5Bs++){if(document.all[nIx5Bs].tagName=='A'){with(document.all[nIx5Bs].style){if(backgroundColor=='yellow'){void(backgroundColor=document.bgColor)}else{void(backgroundColor='yellow')}}}}

If the link colours are so subdued that you can barely see them, for instance, then click the "Highlight links" bookmarklet to display them with a very obvious yellow background. (Click again to remove it.)

Colour-code links
javascript:(function(){var%20i,x;%20for%20(i=0;x=document.links[i];++i)x.style.color=["blue","red","orange"][sim(x,location)];%20function%20sim(a,b)%20{%20if%20(a.hostname!=b.hostname)%20return%200;%20if%20(fixPath(a.pathname)!=fixPath(b.pathname)%20||%20a.search!=b.search)%20return%201;%20return%202;%20}%20function%20fixPath(p){%20p%20=%20(p.charAt(0)=="/"%20?%20""%20:%20"/")%20+%20p;/*many%20browsers*/%20p=p.split("?")[0];/*opera*/%20return%20p;%20}%20})()
(Souce: cybernetnews.com)

This one colour-codes links, so that internal links are red, external ones are blue, and links pointing to the current page are orange. If you don't like these colours then change them to whatever you need.

Linkify
javascript:(function(){var D=document; D.body.normalize(); F(D.body); function F(n){var u,A,M,R,c,x; if(n.nodeType==3){ u=n.data.search(/https?\:\/\/[^\s]*[^.,">\s\)\]]/); if(u>=0) { M=n.splitText(u); R=M.splitText(RegExp.lastMatch.length); A=document.createElement("A"); A.href=M.data; A.appendChild(M); R.parentNode.insertBefore(A,R); } }else if(n.tagName!="STYLE" && n.tagName!="SCRIPT" && n.tagName!="A")for(c=0;x=n.childNodes[c];++c)F(x); } })();
(Souce: cybernetnews.com)

The Linkify bookmarklets converts plain text URLs into clickable hyperlinks, saving you from all that cut and paste hassle.

Open in New Window
javascript:(function(){var a=document.getElementsByTagName('a');for(var i=0,j=a.length;i<j;i++){a[i].setAttribute('target','_blank');var img=document.createElement('img');img.setAttribute('class', 'new-window');img.setAttribute('src','data:image/gif;base64,'+'R0lGODlhEAAMALMLAL66tBISEjExMdTQyBoaGjs7OyUlJWZmZgAAAMzMzP///////wAAAAAAAAAAAAAA'+'ACH5BAEAAAsALAAAAAAQAAwAAAQ/cMlZqr2Tps13yVJBjOT4gYairqohCTDMsu4iHHgwr7UA/LqdopZS'+'DBBIpGG5lBQH0GgtU9xNJ9XZ1cnsNicRADs=');img.setAttribute('style','width:16px!important;height:12px!important;border:none!important;');a[i].appendChild(img);}})();
(Source: doctyper.com)

Sometimes, just occasionally, you might like all links on a page to open in a new window or tab. You can always do the right-click, "Open in New Tab" thing, but it's easier to just click our bookmark and have everything else open in a new window automatically.

Open in Same Window
javascript:(function(){var a=document.getElementsByTagName('a');for(var i=0,j=a.length;i<j;i++){a[i].removeAttribute('target');var img=a[i].getElementsByTagName('img');for(var k=0,l=img.length;k<l;k++){if (img[k].getAttribute('class')=='new-window'){img[k].parentNode.removeChild(img[k]);}}}})();
(Source: doctyper.com)

Here's an undo, something to get links opening in the same window again.

List all links
javascript:var%20a='';for(var%20ln=0;ln%3Cdocument.links.length;ln++){var%20lk=document.links[ln];a+=ln+':%20%3Ca%20href=\''+lk+'\'%20title=\''+lk.text+'\'%3E'+lk+'%3C/a%3E%3Cbr%3E\n';}w=window.open('','Links','scrollbars,resizable,width=400,height=600');w.document.write(a);

If you ever need a list of links on a page then use this bookmarklet to display one.

List email links
javascript:(function(){if(frames.length>1)alert('Sorry,%20frames%20detected.');else{wnd=open('','lnkswnd','width=300,height=200,top=0,left=0,scrollbars,resizable');lnks=document.links;with(wnd.document){writeln('<html>');for(var%20i=0;i<lnks.length;i++){if(lnks[i].href.toLowerCase().substring(0,7)=='mailto:'){writeln('<li><a%20href=\''+lnks[i].href+'\'%20onBlur=\'self.close()\'>'+lnks[i].innerHTML+'</a>%C2%A0('+lnks[i].href.substring(7)+')</li>');}}writeln('</html>');close();}}})()
(Source: subsimple.com)

This bookmarklet will hunt down and display all the email links it finds on the current page, handy if you can't spot them yourself.

Link bookmarklets

LINK LIST: List all the links on a web page in just one click