Utente:Markhurd/hidetopcontrib.js

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

// [[Utente:Markhurd/hidetopcontrib.js]]
// From [[:en:User:Markhurd/hidetopcontrib.js]]
// Based on [[:en:User:Ais523/hidetopcontrib.js]]
// By a suggestion by [[:en:User:Discospinster]]
// 090325 [[:en:User:Markhurd]] Fixed where it is not hiding all (top)s, starting with redirects
//            and continuing after any regex mismatch.
// 090414 [[:en:User:Markhurd]] Convert to wiki-it.
// 090615 [[:en:User:Markhurd]] Cater for new <span class="mw-uctop">
//            Add userHideAllSubsequent user setting.
//            Fix issue reported by [[:en:User talk:Markhurd/hidetopcontrib.js#Bug|Lenore]].
// 110724 [[:en:User:Markhurd]] Use [[:en:User:Waldir]]'s better page check.
// 120207 [[:en:User:Markhurd]] Cater for IE renderer differences.
//                              Also include other en upgrades:
//                                Cater for new pages.
//                                Cater for Single-Revision Deletion (if available to it Admins).
//                                Cater for all skins.
// 120321 [[:en:User:Markhurd]] Cater for [[:en:WP:AORC]].
//                              Also cater for it Classic (standard) skin not having p-cactions
//                              and it Nostalgia skin not having p-cactions or quickbar.
// 150811 [[:en:User:Markhurd]] Cater for depreciated js.

// This script hides lines according to who has the top contribution for a page.
// If userHideAllSubsequent=true, all subsequent contributions are hidden too, more like watchlists.

//<pre><nowiki>

if (typeof userHideAllSubsequent=='undefined')
  userHideAllSubsequent=false;

function hidetopcontrib()
{
   var i,li,a;
   li=document.getElementById("bodyContent");
   if(li===null)
     li=document.getElementById("article");
   if(li===null)
     li=document.getElementById("mw_main");
   li=li.getElementsByTagName("li");
   i=-1;
   a=new Array();
   while(++i<li.length)
   {
     var s,t,links,b;
     links=li[i].getElementsByTagName("a");

     b = 2;
     if(li[i].innerHTML.match(/<abbr +[^>]*class *= *(['"])?newpage\1/i)==undefined) b++;
     if(li[i].innerHTML.match(/class *= *(['"])?mw-revdelundel-link\1/i)!=undefined) b++;

     if (typeof links=='undefined' || links.length<(b+1))
       continue;

     t=links[b].innerHTML;

     if( /* li[i].getElementsByTagName("strong").length>0|| */ li[i].innerHTML.match(/mw\-uctop/i)!=undefined)
       s="none";
     else
       s="";

     if(a[t]!=undefined)
       s=userHideAllSubsequent?"none":a[t];
     else
       a[t]=s;

     if(s!="")
       // li[i].innerHTML=li[i].innerHTML + ":'" + s + "'";
       li[i].style.display=(li[i].style.display=="none"?"list-item":"none");
   }
 }

jQuery(function($) {
   if(mw.config.get('wgCanonicalSpecialPageName') == 'Contributions')
     if(addPortletLink('p-cactions', 'javascript:hidetopcontrib()', 'mostra/nascondi "ultime"', 'ca-hidetop',
                    "Mostra/nascondi pagine in cui sei l'ultimo ad aver editato", '')==undefined)
       if(addPortletLink('quickbar', 'javascript:hidetopcontrib()', 'mostra/nascondi "ultime"', 'ca-hidetop',
                    "Mostra/nascondi pagine in cui sei l'ultimo ad aver editato", '')==undefined)
         mw.util.addPortletLink('topbar', 'javascript:hidetopcontrib()', 'mostra/nascondi "ultime"', 'ca-hidetop',
                    "Mostra/nascondi pagine in cui sei l'ultimo ad aver editato", '');
 });

//</nowiki></pre>
//