User:Splarka/hidetopcontribs.js

/* Contributions (top) edit hider, version [0.0.3] Originally from http://en.wikipedia.org/wiki/User:Splarka/hidetopcontribs.js

On Special:Contributions button hide all pages the current user is top contributor on

Notes:
 * If on an offset or dir URI, one cannot reliably determine top edits, so it isn't active.

if(mw.config.get('wgCanonicalSpecialPageName') && mw.config.get('wgCanonicalSpecialPageName') == 'Contributions' && !queryString('offset') && !queryString('dir')) addOnloadHook(hideTopContribsButton) function hideTopContribsButton { mw.util.addPortletLink('p-cactions','javascript:hideTopContribs','Hide tops','ca-top','Hide all links to pages which this user is the last editor of'); }

function hideTopContribs { var docobj = document.getElementById('bodyContent') || document.getElementById('content') || document.body; var titles = []; var ul = docobj.getElementsByTagName('ul')[0] var tops = getElementsByClassName(ul,'span','mw-uctop'); for(var i=0;i<tops.length;i++) { var histlink = tops[i].parentNode.getElementsByTagName('a')[0].href; titles.push(histlink); }

var li = ul.getElementsByTagName('li'); for(var i=0;i<li.length;i++) { var lihl = li[i].getElementsByTagName('a')[0].href; for(var j=0;j<titles.length;j++) { if(lihl == titles[j]) { li[i].style.display = 'none'; }   }  } }

function queryString(p) { var re = RegExp('[&?#]' + p + '=([^&#]*)'); var matches; if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { } }  return null; }