/* http://greasemonkey.mozdev.org */

// ==UserScript==
// @name            Footnote links
// @namespace       http://akkartik.name/greasemonkey
// @description     Converts footnotes to links.
// @include         http://*.gmane.org/*
// ==/UserScript==

(function() {
  var h = document.body.innerHTML;
  document.body.innerHTML = h.replace(/[\[\*](\d+)[\*\]]/g, function(m, n) {
    if (typeof arguments.callee.vars != 'object') {
      arguments.callee.vars = {};
    }
    if (arguments.callee.vars[n]) {
      return '[<a href="#ft'+n+'" id="fb'+n+'">'+n+'</a>]';
    } else {
      arguments.callee.vars[n] = 1;
      return '[<a href="#fb'+n+'" id="ft'+n+'">'+n+'</a>]';
    }
  });
})();

