LXR Filename Reference Search

By Alexander J. Vincent Last update Aug 11, 2005 — Installed 1,304 times. Daily Installs: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
// ==UserScript==
// @name LXR Filename Reference Search
// @description Creates a link in LXR to search for the filename in other files.
// @include http://lxr.mozilla.org/*
// ==/UserScript==
(function() {
  if (location.href.indexOf("/source/") == -1)
    return;
  var crumbs = document.getElementsByTagName("b")[1];
  var path = "http://lxr.mozilla.org/" + crumbs.firstChild.firstChild.nodeValue;
  var lastText = crumbs.lastChild.nodeValue;
  if (lastText == "/ ")
    return;
  var filename = crumbs.lastChild.previousSibling.firstChild.nodeValue;
  path += "/search?string=" + encodeURIComponent(filename);
  var hlink = document.createElement("a");
  hlink.setAttribute("href", path);
  hlink.appendChild(document.createTextNode("References"));
  var add_on = document.createElement("em");
  add_on.appendChild(document.createTextNode("("));
  add_on.appendChild(hlink);
  add_on.appendChild(document.createTextNode(")"));
  crumbs.appendChild(add_on);
})();