Jump to content

User:Cryptic/relatedchanges.js

From Wikipedia, the free encyclopedia
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;
      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 (a[0].firstChild.data == "diff")
                  if (entries[a[2].href] == 'y')
                    li[j].style.display = 'none';
                  else
                    {
                      a[0].href = a[0].href.replace(/&curid=[0-9]+/, '');
                      entries[a[2].href] = 'y';
                    }
              }
          }
    }
});
// </nowiki></pre>