Add Favicons to External Links – Bookmarklet

This little JavaScript bookmarklet will add favicons and some CSS styles to all external hyperlinks on a web page. The favicon images of a website are fetched using Google’s favicon generator that was originally part of Google Reader. And here are some more useful bookmarklets for your browser.

// Highlight External Links by Amit Agarwal
// Published on 06/09/2012

// Find the domain name of the current page
var host =;

// Use Google's Favicon Generator
var goog = "";

// Find all hyperlinks on a web page
var links = document.getElementsByTagName("a");

for (i=0; i<links.length; i++) {

  var link = links[i];

  // Skip all internal links where the href is the same as the domain host
  // Also skip non HTTP links like FTP, MAILTO, etc.

  if(link.href.match("^https?://") && !link.href.match(host)) {

    var domain = link.href.split("/");

    // Apply some CSS styles to the external hyperlinks = "url(" + goog + domain[2] + ") center left no-repeat"; = "bold"; = "105%";"5px 5px 5px 20px";"underline";