Utilisateur:Dr Brains/AbuseLogDeluxe.js
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./*
{{Projet:JavaScript/Script}}
*/
if((mw.config.get('wgCanonicalSpecialPageName')=="AbuseLog")&&(mw.config.get('wgTitle').indexOf('/')==-1)){
addOnloadHook(AbuseLogDeluxe);
document.write('<style type="text/css">'
+'.AbuseLogDeluxe_Running{'
+'font-weight:bold;'
+'background-color:silver;'
+'border:1px solid black;'
+'}'
+'</style>');
}
addOnloadHook(AbuseLogDeluxe_AddLink);
function AbuseLogDeluxe_AddLink(){
var RCLi = document.getElementById("n-recentchanges");
if(RCLi){
var AbuseLogLi = document.createElement('li');
AbuseLogLi.id = "n-abuselog";
AbuseLogLi.innerHTML = '<a href="'+mw.config.get('wgServer')+mw.config.get('wgArticlePath').split('$1').join('Special:AbuseLog')+'" title="Journal des filtrages">Journal des filtrages</a>';
RCLi.parentNode.insertBefore(AbuseLogLi, RCLi.nextSibling);
}
}
function AbuseLogDeluxe(){
var Content = document.getElementById('bodyContent');
if(!Content) Content = document.getElementById('mw_contentholder');
if(!Content) Content = document.getElementById('article');
if(!Content) return;
if(mw.config.get('wgUserGroups').indexOf("sysop")!=-1){
var IsSysop = 1;
}else{
var IsSysop = 0;
}
var NewMenuText = '<a id="ShowRedPagesLink" style="display:none;" '
+'href="javascript:AbuseLogDeluxe_ToggleRedPages(\'none\',\'inline\',\'block\');" '
+'title="Cliquer pour afficher les pages supprimées" >afficher</a>'
+'<a id="HideRedPagesLink" '
+'href="javascript:AbuseLogDeluxe_ToggleRedPages(\'inline\',\'none\',\'none\');" '
+'title="Cliquer pour masquer les pages supprimées" >masquer</a> les pages supprimées'
+' | '
+'<a id="ShowTopUsers" '
+'href="javascript:AbuseLogDeluxe_ShowTopUsers(\'ShowTopUsers\',\'HideTopUsers\');" '
+'title="Cliquer pour afficher les utilisateurs les plus suspects" >afficher</a>'
+'<a id="HideTopUsers" style="display:none;" '
+'href="javascript:AbuseLogDeluxe_HideTopUsers(\'ShowTopUsers\',\'HideTopUsers\');" '
+'title="Cliquer pour masquer les utilisateurs les plus suspects" >masquer</a> les utilisateurs les plus suspects';
NewMenuText += '<fieldset id="TopUsersDiv" style="display:none;"><legend>Classement des utilisateurs les plus suspects</legend><div style="height:600px;overflow-y:auto;"></div></fieldset>';
var Menu = Content.getElementsByTagName('fieldset')[0];
var NewMenuOptions = document.createElement('div');
NewMenuOptions.id = "AbuseLogOptions";
NewMenuOptions.innerHTML = NewMenuText;
Menu.appendChild(NewMenuOptions);
var Lignes = Content.getElementsByTagName('li');
for(var a=0;a<Lignes.length;a++){
var UserLink = Lignes[a].getElementsByTagName('a')[0];
var TalkLink = Lignes[a].getElementsByTagName('a')[1];
var ContribLink = Lignes[a].getElementsByTagName('a')[2];
if(ContribLink.innerHTML == "contributions"){
ContribLink = false;
var IsIp = 1;
}else{
var IsIp = 0;
}
if(IsSysop==1) var BlockLink = Lignes[a].getElementsByTagName('a')[(2+IsIp)];
var FilterLink = Lignes[a].getElementsByTagName('a')[(2+IsIp+IsSysop)];
var PageLink = Lignes[a].getElementsByTagName('a')[(3+IsIp+IsSysop)];
var DetailsLink = Lignes[a].getElementsByTagName('a')[(4+IsIp+IsSysop)];
var ExaminLink = Lignes[a].getElementsByTagName('a')[(5+IsIp+IsSysop)];
var User = UserLink.innerHTML;
var Page = PageLink.innerHTML;
var PageLinks = document.createElement('span');
PageLinks.innerHTML = ' ('
+'<a href="'
+mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + Page + '&action=history" '
+'title="Historique" >historique</a>'
+' | '
+'<a href="'
+mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=Special:Log&page=Accueil" '
+'title="Journaux d\'opérations">Journal</a>'
+')';
PageLink.parentNode.insertBefore(PageLinks,PageLink.nextSibling);
}
}
function AbuseLogDeluxe_ToggleRedPages(ShowLinkState,HideLinkState, LiState){
var ShowLink = document.getElementById("ShowRedPagesLink");
var HideLink = document.getElementById("HideRedPagesLink");
var Content = document.getElementById('bodyContent');
if(!Content) Content = document.getElementById('mw_contentholder');
if(!Content) Content = document.getElementById('article');
if((!Content)||(!ShowLink)||(!HideLink)) return;
ShowLink.style.display = ShowLinkState;
HideLink.style.display = HideLinkState;
var Lignes = Content.getElementsByTagName('li');
if(mw.config.get('wgUserGroups').indexOf("sysop")!=-1){
var IsSysop = 1;
}else{
var IsSysop = 0;
}
for(var a=0;a<Lignes.length;a++){
var ContribLink = Lignes[a].getElementsByTagName('a')[2];
if(ContribLink.innerHTML == "contributions"){
var IsIp = 1;
}else{
var IsIp = 0;
}
var PageLink = Lignes[a].getElementsByTagName('a')[(3+IsIp+IsSysop)];
if($(PageLink).hasClass("new")) Lignes[a].style.display = LiState;
}
}
function AbuseLogDeluxe_ShowTopUsers(IdShow,IdHide){
var ShowLink = document.getElementById(IdShow);
var HideLink = document.getElementById(IdHide);
var TopUsersDiv = document.getElementById("TopUsersDiv");
var Content = document.getElementById('bodyContent');
if(!Content) Content = document.getElementById('mw_contentholder');
if(!Content) Content = document.getElementById('article');
if((!Content)||(!ShowLink)||(!HideLink)||(!TopUsersDiv)) return;
HideLink.style.display = "inline";
ShowLink.style.display = "none";
TopUsersDiv.style.display = "block";
var UserList = new Array()
var UserListCount = -1;
var Lignes = Content.getElementsByTagName('li');
for(var a=0;a<Lignes.length;a++){
var UserName = Lignes[a].getElementsByTagName('a')[0].innerHTML;
UserListCount++
UserList[UserListCount] = UserName;
}
var ArrayTemp = UserList.sort();
var TopUsers = new Array();
var TopUsersCount = -1
var count = 1;
for(var b=0;b<ArrayTemp.length;b++){
if(ArrayTemp[(b+1)]){
if(ArrayTemp[b]==ArrayTemp[(b+1)]){
count++
}else{
TopUsersCount++
if(count<10){ var ZeroCount = '0';}else{ var ZeroCount = ''}
TopUsers[TopUsersCount] = '<li><b>'+ZeroCount+count+'</b> <a href="javascript:AbuseLogDeluxe_ToggleDetails(\''+ArrayTemp[b]+'\');" title="Voir les détails pour cet utilisateur">'+ArrayTemp[b]+'</a></li>';
count=1;
}
}else{
TopUsersCount++
if(count<10){ var ZeroCount = '0';}else{ var ZeroCount = ''}
TopUsers[TopUsersCount] = '<li><b>'+ZeroCount +count+'</b> <a href="javascript:AbuseLogDeluxe_ToggleDetails(\''+ArrayTemp[b]+'\');" title="Voir/Masquer les détails pour cet utilisateur">'+ArrayTemp[b]+'</a></li>';
count=1;
}
}
TopUsers = TopUsers.sort();
var TopUsersDivContent = '<ul>';
for(var c=(TopUsers.length-1);c>0;c--){
TopUsersDivContent += TopUsers[c];
}
TopUsersDivContent += '</ul>';
TopUsersDiv.getElementsByTagName('div')[0].innerHTML = TopUsersDivContent;
var FirstUser = TopUsersDiv.getElementsByTagName('li')[0];
AbuseLogDeluxe_GetBlockedUsers(FirstUser);
}
function AbuseLogDeluxe_GetBlockedUsers(element){
element.className = "AbuseLogDeluxe_Running";
var UserName = element.getElementsByTagName('a')[0].innerHTML;
var AdresseRequete = mw.config.get('wgServer') + '/w/api.php?action=query&list=blocks&bkusers=' + UserName;
var NouvelleRequete = new XMLHttpRequest();
NouvelleRequete.open("GET", AdresseRequete, true);
NouvelleRequete.send(null);
NouvelleRequete.onreadystatechange = function() {
if(NouvelleRequete.readyState == 4 && NouvelleRequete.status == 200) {
var ElementTraitement = document.createElement('div');
ElementTraitement.innerHTML = NouvelleRequete.responseText;
var Informations = ElementTraitement.getElementsByTagName('span');
var UserBlocked = false;
for(a=0;a<Informations.length;a++){
var ContenuInformation = Informations[a].innerHTML;
if(ContenuInformation.indexOf('user=')!=-1){
UserBlocked = true;
}
}
if(UserBlocked==true) element.innerHTML = '<s>' + element.innerHTML + '</s> Utilisateur bloqué';
var nextElement = element.nextSibling;
if(nextElement) AbuseLogDeluxe_GetBlockedUsers(nextElement);
element.className = "";
}
}
}
function AbuseLogDeluxe_HideTopUsers(IdShow,IdHide){
var ShowLink = document.getElementById(IdShow);
var HideLink = document.getElementById(IdHide);
var TopUsersDiv = document.getElementById("TopUsersDiv");
HideLink.style.display = "none";
ShowLink.style.display = "inline";
TopUsersDiv.style.display = "none";
TopUsersDiv.getElementsByTagName('div')[0].innerHTML = '';
}
function AbuseLogDeluxe_ToggleDetails(UserName){
var TopUsersDiv = document.getElementById("TopUsersDiv");
var Content = document.getElementById('bodyContent');
if(!Content) Content = document.getElementById('mw_contentholder');
if(!Content) Content = document.getElementById('article');
if((!Content)||(!TopUsersDiv)) return;
var AllLink = TopUsersDiv.getElementsByTagName('a');
for(var b=0;b<AllLink.length;b++){
if(AllLink[b].innerHTML == UserName){
var TheLink = AllLink[b];
}
}
if(!TheLink) return;
var DetailsUl = document.getElementById('AbuseLogDeluxe_Details_'+UserName);
if(!DetailsUl){
var DetailsUl = document.createElement('ul');
DetailsUl.id= "AbuseLogDeluxe_Details_"+UserName;
var Details = '';
var Lignes = Content.getElementsByTagName('li');
for(var a=0;a<Lignes.length;a++){
var ThisUserLink = Lignes[a].getElementsByTagName('a')[0]
var ThisUserName = ThisUserLink.innerHTML;
if((ThisUserName==UserName)&&(ThisUserLink.href.indexOf('javascript')==-1)) Details += '<li>' + Lignes[a].innerHTML + '</li>';
}
DetailsUl.innerHTML = Details;
TheLink.parentNode.appendChild(DetailsUl);
}else{
DetailsUl.parentNode.removeChild(DetailsUl);
}
}