Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
/* Contributions (top) edit hider, version [0.0.4] Originally from http://en.wikipedia.org/wiki/User:Splarka/hidetopcontribs.jsRepairs by user jmcgnh 2017-10-22On Special:Contributions page, add button to hide all pages the current user is top contributor onNotes:* If on an offset or dir URI, one cannot reliably determine top edits, so it isn't active.* When I use this, I am also uninterested in seeing my own earlier contributions, so we only want to display the latest of my own contribs*/// This first stanza checks to see if the current page is a Special Contributions page and adds a button hooking into this scriptif(mw.config.get('wgCanonicalSpecialPageName')&&mw.config.get('wgCanonicalSpecialPageName')=='Contributions'&&!queryString('offset')&&!queryString('dir'))addOnloadHook(hideTopContribsButton);functionhideTopContribsButton(){mw.util.addPortletLink('p-tb','javascript:hideTopContribs()','Hide tops','tb-top','Hide all links to pages which this user is the last editor of');}functionhideTopContribs(){vardocobj=document.getElementById('bodyContent')||document.getElementById('content')||document.body;vartitles=[];varul=docobj.getElementsByTagName('ul')[0];// pick first list (checked that this is the right index)vartops=ul.getElementsByClassName('mw-uctop');// this mw-uctop class name is present when the entry is marked "(current)" to say that this user is the most recent contributorfor(vari=0;i<tops.length;i++){vartitlelink=tops[i].parentNode.getElementsByTagName('a')[0].title;// pulls title attribute from first <a> link in the entrytitles.push(titlelink);// keep track of titles of entries flagged with mw-uctop// console.log("pushing title=", titlelink);}varli=ul.getElementsByTagName('li');for(i=0;i<li.length;i++){varlititle=li[i].getElementsByTagName('a')[0].title;varseen=0;for(varj=0;j<titles.length;j++){if(lititle==titles[j]){li[i].style.display='none';seen=1;}}if(!seen){titles.push(lititle);// console.log("pushing li title=", lititle);}}}functionqueryString(p){// I think this works because I can see the buttton appearingvarre=RegExp('[&?#]'+p+'=([^&#]*)');varmatches;if(matches=re.exec(document.location)){try{returndecodeURI(matches[1]);}catch(e){}}returnnull;}