Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
if(typeof(SysopWatch) === "undefined" && mw.config.get('wgPageName') == "Utilisateur:Dr_Brains/SysopWatch.js" && mw.config.get('wgAction') != "edit" && mw.config.get('wgAction') != "sumit"){ // START IF

var SysopWatch = new Object()


SysopWatch.Function = new Object();

 
SysopWatch.Function.ajax = {
  http:function(bundle){ var xmlhttp; try{ xmlhttp = new XMLHttpRequest(); }catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ xmlhttp = false; }}}; if(xmlhttp){ xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4){ SysopWatch.Function.ajax.httpComplete(xmlhttp,bundle);}}; xmlhttp.open(bundle.method ? bundle.method : "GET",bundle.url,bundle.async == false ? false : true); if (bundle.headers) { for (var field in bundle.headers){ try{ xmlhttp.setRequestHeader(field,bundle.headers[field]); }catch(err){}}}; xmlhttp.send(bundle.data ? bundle.data : null); }; return xmlhttp;},
  httpComplete: function(xmlhttp,bundle){ if(xmlhttp.status == 200 || xmlhttp.status == 302){ if(bundle.onSuccess) bundle.onSuccess(xmlhttp,bundle); }else if(bundle.onFailure){ bundle.onFailure(xmlhttp,bundle); }else{ }}
};

SysopWatch.Function.List = function(List, listcontinue){
    if(!List) List = new Object();
    if(!listcontinue) listcontinue = "";

    var APILimit = ((mw.config.get('wgUserGroups').indexOf("sysop")!=-1 || mw.config.get('wgUserGroups').indexOf("bot")!=-1) ? 4999 : 499 );
    var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php?format=xml"
            + "&action=query&list=logevents"
            + "&letype=rights&lelimit=" + APILimit
            + listcontinue;

    SysopWatch.Function.ajax.http({
          url: URL,
          list: List,
          onSuccess:SysopWatch.Function.ListDone
    });

}

SysopWatch.Function.ListDone = function(Req, data){
     var List = data.list;
     var ObjetXML = Req.responseXML;
     var Items = ObjetXML.getElementsByTagName('item');
     for(a=0;a<Items.length;a++){
         var Item = Items[a];
         var Rights = Item.firstChild;
         if(!Rights) continue;
         var OldRights = (Rights.getAttribute("old").indexOf("sysop") != -1);
         var NewRights = (Rights.getAttribute("new").indexOf("sysop") != -1);
         if( ( (OldRights ? 1 : 0) + (NewRights ? 1 : 0)) != 1) continue;
         var UserName = Item.getAttribute("title").split(mw.config.get('wgFormattedNamespaces')[2]+":").join("");
         var Time = Item.getAttribute("timestamp");
         if(!List.UserName) List.UserName = new Object();
         List.UserName[Time] = ( (OldRights && !NewRights) ? -1 : 1 );
     }
     var ListContinue = ObjetXML.getElementsByTagName('query-continue')[0];
     if(ListContinue){
         var AutreRequeteContinue = '&lestart=' + encodeURIComponent(ListContinue.firstChild.getAttribute("lestart"));
         Unwatchedpages_RunRequest(List, AutreRequeteContinue);
     }else{
         SysopWatch.Function.MakeList(List);
     }
}

SysopWatch.Function.MakeList = function(List){
     var Text = "";
     for(var UserName in List){
         Text += ";{{u|" + UserName + "}}\n";
         var Infos = List.UserName;
         for(var Time in Infos){
             var Change = Infos[Time];
             Text += '* <span style="color:' + (Change>0 ? "green": "red") + '">' +  Change +  "(" + Time + ")"+ "</span>\n";
         }
     }
     SysopWatch.Function.DisplayList(Text);
}

SysopWatch.Function.DisplayList = function(Text){
   var Txtarea = document.getElementById("SysopWatchTextarea");
   if(!) {
   Txtarea = document.createElement("textarea");
   Txtarea.id = "SysopWatchTextarea";
   document.body.insertBefore(Txtarea, document.body.firstChild);
   }
   Txtarea.value = Text;
}

 
SysopWatch.Function.AddLink(){
     var OngletsCactions = document.getElementById('p-cactions');
     if(OngletsCactions){
          var CactionsUl = OngletsCactions.getElementsByTagName('ul')[0];
          CactionsUl.innerHTML += '<li><a href="javascript:SysopWatch.Function.List();">SysopWatch Run</a></li>';
          if(OngletsCactions.className){
               OngletsCactions.className = OngletsCactions.className.replace(/[ ]*emptyPortlet[ ]*/, " ");
          }
     }
}

addOnloadHook(SysopWatch.Function.AddLink);

} // END IF