Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to have Firefox add-on which recognizes a website page and automatically redirects to link in the page identified its XPath.

Once example where it will be useful is the news aggregator sites like DZone. Whenever I click a DZone RSS feed's link it goes the DZone website and only after clicking the link it jumps to the actual blog/news page. I want to automatically jump to the actual content/blog/news page when I land the DZone site.

Let me know if there such an add-on available for Firefox.

share|improve this question
up vote 0 down vote accepted

Sounds it would be easy to create Greasemonkey userscript to do so.

Greasemonkey scripts are launched only on URLs matching the expreession you provide (so you can write sth like "*), and they are executed once page is loaded (top be more more detailed: when DOMContentLoaded event fires).

Writing a script should be easy with just plain JavaScript and XPath. You need to read some value by XPath like you say, and then to do the redirect, set window.location = ....

If I understood you correctly, you can use the following code - works for me in Firefox 7.0.1 / Greasemonkey 0.9.11

// ==UserScript==
// @name           Dzone Automatic Redirect
// @namespace      userscript_dzone
// @include*
// ==/UserScript==

   var XPathTools = 
      getElementByXpath : function(xpath, referenceNode)
         var xPathResult = document.evaluate (xpath, referenceNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
         return xPathResult.singleNodeValue;

   var xpath = "//div[@id='linkDetails']//div[@class='ldTitle']/a";
   var url = XPathTools.getElementByXpath(xpath,document);
   window.location = url;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.