Show link destination on hover

By Phil Wilson Last update Mar 31, 2009 — Installed 97 times. Daily Installs: 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 2, 2, 7, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0
// ==UserScript==
// @name           Show link destination on hover
// @namespace      http://philwilson.org/
// @description    Shows the URL a link goes to on hover. Good when status bar is disabled
// @include        *
// @version        0.1
// ==/UserScript==


// find every link and insert a title attribute the same as the href, appending to any existing @title
(function(){

    var links = document.evaluate("//a", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

    for (var x=0;x<links.snapshotLength;x++) {
      link = links.snapshotItem(x);
      if (link.getAttribute("title")==null) {
          link.setAttribute("title", link.getAttribute("href"));
      } else {
          link.setAttribute("title", link.getAttribute("title")+" ("+link.getAttribute("href")+")");
      }
    }


})();