http://www.onlinesales.co.uk/blog - Testing Your Way To Success OnlineOnline Sales

UK Conversion & Search Optimisation Services

Links On Page Bookmarklet pt. ii

After I wrote the Google Results Bookmarklet some feedback form Marty Lamers led me to revise my previous Onpage Links Bookmarklet to also include the text boxes that make it easy to grab the links.

I’ve updated the styling to highlight the nofollow links, and to “stripe” the output to make it easier to read.

At the bottom of the page I’ve created several of the textarea boxes, so you can grab various types of links:

  • All the no followed links
  • All the followed links
  • Just the external links
  • Just the external followed links
  • The external nofollowed links

Once more drag the link in the big green box to your bookmark bar and when you’ve on a page you want to analyse hit the bookmarklet. It will open a new window showing all the links and with several text boxes with the links as detailed above.

Links On Page

Here’s the code:

javascript:(function(){var hostname=window.location.hostname; hostname=hostname.replace("www.","").toLowerCase(); this.check = function(obj){var href = obj.href.toLowerCase(); return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? true : false; }; strhead="<link href='http://www.onlinesales.co.uk/seo/bookmarklet/seo.css' rel='stylesheet' type='text/css'>\n"; anchors=document.getElementsByTagName("a"); str="<table>"; str+="<tr><th>#</th><th>HREF</th><th>Anchor</th><th>Rel</th></tr>\n"; var allExternal=allExternalFollow=allExternalNoFollow=allLinks=allFollow=allFollowLinks=allNoFollow=allNoFollowLinks=""; var nflc=flc=xlc=xflc=xnflc=0; for(i=0;i<anchors.length;i++){var j=i+1; var anchorText = anchors[i].textContent; var anchorRel = anchors[i].rel; if(anchorText === undefined){anchorText = anchors[i].innerText; }if(j%2=='0'){if(anchorRel.match(/nofollow/i)){str+="<tr style='background-color:#ddcccc;'>"; }}else{str+="<tr style='background-color:#eeeeee;'>"; if(anchorRel.match(/nofollow/i)){str+="<tr style='background-color:#ccbbbb;'>"; }}str+="<td>"+j+"</td>"; str+="<td><a href="+anchors[i].href+">"+anchors[i].href+"</a></td>"; str+="<td>"+anchorText+"</td>"; str+="<td>"+anchorRel+"</td>"; str+="</tr>\n"; allLinks+=anchors[i].href+"\n"; if(anchorRel.match(/^(?!nofollow)/i)){allFollow+=anchors[i].href+"\n"; allFollowLinks+="<a href=\""+anchors[i].href+"\">"+anchorText+"</a>\n"; flc=flc+1; }else{allNoFollow+=anchors[i].href+"\n"; allNoFollowLinks+="<a href=\""+anchors[i].href+"\">"+anchorText+"</a>\n"; nflc=nflc+1; }if(check(anchors[i])){allExternal+=anchors[i].href+"\n"; xlc=xlc+1; if(anchorRel.match(/^(?!nofollow)/i)){allExternalFollow+=anchors[i].href+"\n"; xflc=xflc+1; }else{allExternalNoFollow+=anchors[i].href+"\n"; xnflc=xnflc+1; }}}str+="</table><br/> <br/><a name=a></a><h2>All Links ("+j+")</h2><textarea cols=80 rows=10>"; str+=allLinks; str+="</textarea><br/> <br/><a name=b></a><h2>Followed Links ("+flc+")</h2><textarea cols=80 rows=10>"; str+=allFollow; str+="</textarea><br/> <br/><a name=c></a><h2>NoFollowed Links ("+nflc+")</h2><textarea cols=80 rows=10>"; str+=allNoFollow; str+="</textarea><br/> <br/><a name=d></a><h2>All External Links ("+xlc+")</h2><textarea cols=80 rows=10>"; str+=allExternal; str+="</textarea><br/> <br/><a name=e></a><h2>External Follow Links ("+xflc+")</h2><textarea cols=80 rows=10>"; str+=allExternalFollow; str+="</textarea><br/> <br/><a name=f></a><h2>External NoFollow Links ("+xnflc+")</h2><textarea cols=80 rows=10>"; str+=allExternalNoFollow; str+="</textarea><br/> <br/><p align=center><a href='http://www.onlinesales.co.uk/'>Bookmarklet by Liam Delahunty of Online Sales</a></p>"; strhead+="<table><tr><td>"+j+"</td><td><a href='#a'>Links on page.</a></td></tr><tr><td>"+flc+"</td><td><a href='#b'>Followed links.</a></td></tr><tr><td>"+nflc+"</td><td><a href='#c'>No followed links.</a></td></tr><tr><td>"+xlc+"</td><td><a href='#d'>External Links</a></td></tr><tr><td>"+xflc+"</td><td><a href='#e'>External Followed Links</a></td></tr><tr><td>"+xnflc+"</td><td><a href='#f'>External Nofollowed Links</a></td></tr></table>"; doc=strhead+str; with(window.open()){document.write(doc); document.close();}})() 

"Links On Page Bookmarklet pt. ii" was published on December 10th, 2009 and is listed in Tools.

Follow comments via the RSS Feed | Leave a comment | Trackback URL

Comments on "Links On Page Bookmarklet pt. ii": 2 Comments

  1. Martypants wrote,

    Spot-on, Liam.
    Note to all: running this script allowed me to find a pinhole in my CMS – a potentially dangerous opening I could not see on the page. Seeing it in Liam’s report from this Bookmarklet, I was able to quickly close it and prevent any issues.
    This is a fine little tool that has already done me a world of good – outstanding work.

  2. Reading On The Toilet | Cool Bookmarklets wrote,

    [...] Links on Page & Google Results Bookmarklet [...]

Leave Your Comment