User:Markhurd/watchcontrib.js
Appearance
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. |
![]() | Documentation for this user script can be added at User:Markhurd/watchcontrib. |
// Based on [[User:MarkHurd/hidetopcontrib.js]]
// [[User:Ais523/hidetopcontrib.js]]
// By a suggestion by [[User:Discospinster]]
// 090325 MEH Fixed where it is not hiding all (top)s, starting with redirects
// and continuing after any regex mismatch.
// 090615 MEH Cater for new <span class="mw-uctop">
// Add userHideAllSubsequent user setting.
// This script hides lines according to who has the top contribution for a page.
if (typeof userHideAllSubsequent=='undefined')
userHideAllSubsequent=false;
//<pre><nowiki>
function watchcontrib()
{
var i,li,a;
li=document.getElementById("bodyContent");
li=li.getElementsByTagName("li");
i=-1;
a=new Array();
while(++i<li.length)
{
var s,t,links;
links=li[i].getElementsByTagName("a");
if(false)
{ if (!(typeof links=='undefined' || links.length<4))
//continue;
{// /*li[i]*/
t=links[3].innerHTML.match(/"\/wiki\/([^"]*)"/); // " fix simple WP syntax highlighter
if(t!=undefined)
t=t[1];
else
{ //li[i]
t=links[3].innerHTML.match(/"\/w\/index\.php\?title\=([^&]*)\&\;redirect\=no"/);
if(t!=undefined)
t=t[1];
else
continue;
}
if(li[i].getElementsByTagName("strong").length>0||li[i].innerHTML.match(/\<span +class\="mw\-uctop"\>/)!=undefined)
s="none";
else
s="";
if(a[t]!=undefined)
s=userHideAllSubsequent?"none":a[t];
else
a[t]=s;
}}
//if(s!="")
if (typeof links!='undefined')
{ s = ":" + links.length.tostring;
li[i].innerHTML=li[i].innerHTML + s +":" + (links.length>=4)?("("+links[3].innerHTML+")"):"";}
// li[i].innerHTML=li[i].innerHTML + ":" + s + ":'" + t + "'";
// li[i].style.display=(li[i].style.display=="none"?"list-item":"none");
}
}
addOnloadHook(function () {
if((location.href.indexOf("Special:Contributions")!=-1||
location.href.indexOf("Special%3AContributions")!=-1))
addPortletLink('p-cactions', 'javascript:watchcontrib()', 'debug top v1', 'ca-watchtop',
"Show/hide pages for which you're the top contributor", '');
});
//</nowiki></pre>
//[[:Category:Wikipedia scripts]]