Jump to content

User:Cryptic/relatedchanges.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Cryptic (talk | contribs) at 16:14, 28 December 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
<pre><nowiki>
// Only show the most recent change to each article in Related Changes.
// Also change the diff links so they're the same urls as the History page (and thus show up in the "visited" color).
addOnloadHook(function ()
{
  if (document.title == 'Related changes - Wikipedia, the free encyclopedia')
    {
      var uls = document.getElementsByTagName('ul');
      var entries = new Object;
      var to_remove = new Array;
      for (var i = 0; i < uls.length; ++i)
        if (uls[i].className && uls[i].className.indexOf('special') >= 0)
          {
            var ul = uls[i];
            var li = ul.getElementsByTagName('li');
            for (var j = 0; j < li.length; ++j)
              {
                var a = li[j].getElementsByTagName('a');
                if (entries[a[2]] == 'y')
                  to_remove[to_remove.length] = j;
                else
                  {
                    a[0].href = a[0].href.replace(/&curid=[0-9]+/, '');
                    entries[a[2]] = 'y';
                  }
              }
            for (var j = to_remove.length; j >= 0; --j)
              ul.removeChild(li[to_remove[j]]);
          }
    }
});
</nowiki></pre>