Utilisateur:Dr Brains/WhatlinkshereDeluxe.js
Apparence
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./*
{{Sommaire à droite}}
= Informations =
* Author : Dr Brains ( https://fr.wikipedia.org/wiki/Utilisateur:Dr_Brains )
* License : CC0
* Documentation : https://fr.wikipedia.org/wiki/Projet:JavaScript/Notices/WhatlinkshereDeluxe
{{Catégorisation JS|WhatlinkshereDeluxe}}
= Code source =
<syntaxhighlight lang=javascript> */
if(typeof(WhatlinkshereDeluxeLoaded)==="undefined") {
window.WhatlinkshereDeluxeLoaded = true;
mw.loader.using('mediawiki.util', function () {
"use strict";
/* </syntaxhighlight>
== Options ==
<syntaxhighlight lang=javascript> */
window.WhatlinkshereDeluxe_PreloadOnCategoryPage = false;
/* </syntaxhighlight>
== Textes ==
<syntaxhighlight lang=javascript> */
window.WhatlinkshereDeluxe_Texts = {
"WhatLinksHere" : "Pages liées",
"WhatLinksHereDetailsTitle" : "Voir les pages liées à « $1 » (nouvel onglet)",
"WhatLinksHereDetailsText" : "(détails)",
"WhatLinksHereLongALL_None" : "<b>Aucune</b> page ne contient de lien vers la page « <b>$2</b> » $3",
"WhatLinksHereLongALL_One" : "$1 page contient un ou plusieurs liens vers la page « <b>$2</b> » $3",
"WhatLinksHereLongALL_Several" : "$1 pages contiennent un ou plusieurs liens vers la page « <b>$2</b> » $3",
"WhatLinksHereLongBLR_None" : "<b>Aucune</b> page ne redirige vers la page « $2 »",
"WhatLinksHereLongBLR_One" : "$1 page redirige vers la page « $2 »",
"WhatLinksHereLongBLR_Several" : "$1 pages redirigent vers la page « $2 »",
"WhatLinksHereLongBLNR_None" : "<b>Aucune</b> page n’a lien vers la page « $2 »",
"WhatLinksHereLongBLNR_One" : "$1 page a un lien vers la page « $2 »",
"WhatLinksHereLongBLNR_Several" : "$1 pages ont un lien vers la page « $2 »",
"WhatLinksHereLongEI_None" : "<b>Aucune</b> page n’inclut la page « $2 »",
"WhatLinksHereLongEI_One" : "$1 page inclut la page « $2 »",
"WhatLinksHereLongEI_Several" : "$1 pages incluent la page « $2 »",
"WhatLinksHereLongIU_None" : "<b>Aucune</b> page n’affiche le fichier « $2 »",
"WhatLinksHereLongIU_One" : "$1 page affiche le fichier « $2 »",
"WhatLinksHereLongIU_Several" : "$1 pages affichent le fichier « $2 »",
"WhatLinksHereShortALL_None" : "<b>Aucune</b> page ne contient de lien vers cette page $3",
"WhatLinksHereShortALL_One" : "$1 page contient un ou plusieurs liens vers cette page $3",
"WhatLinksHereShortALL_Several" : "$1 pages contiennent un ou plusieurs liens vers cette page $3",
"WhatLinksHereShortBLR_None" : "<b>Aucune</b> redirection",
"WhatLinksHereShortBLR_One" : "$1 redirection",
"WhatLinksHereShortBLR_Several" : "$1 redirections",
"WhatLinksHereShortBLNR_None" : "<b>Aucun</b> lien",
"WhatLinksHereShortBLNR_One" : "$1 lien",
"WhatLinksHereShortBLNR_Several" : "$1 liens",
"WhatLinksHereShortEI_None" : "<b>Aucune</b> inclusion",
"WhatLinksHereShortEI_One" : "$1 inclusion",
"WhatLinksHereShortEI_Several" : "$1 inclusions",
"WhatLinksHereShortIU_None" : "<b>Aucun</b> usage du fichier",
"WhatLinksHereShortIU_One" : "$1 usage du fichier",
"WhatLinksHereShortIU_Several" : "$1 usages du fichier",
"WLH_SeeOnly_WithoutFile" : "(ne voir que : $1, $2 ou $3)",
"WLH_SeeOnly_WithFile" : "(ne voir que : $1, $2, $3 ou $4)",
"WLH_SeeOnly_EI" : "les inclusions",
"WLH_SeeOnly_BLNR" : "les liens",
"WLH_SeeOnly_BLR" : "les redirections",
"WLH_SeeOnly_IU" : "les fichiers liés",
"ListLinkTitle" : "Afficher/Masquer la liste des pages",
"ListLinkText" : "[liste]",
"DoubleRedirects" : "Doubles redirections $1",
"DoubleRedirects_HelpPage" : "Aide:Double redirection",
"DoubleRedirects_HelpTitle" : "Aide sur les doubles redirections (nouvel onglet)",
"DoubleRedirects_HelpText" : "(aide)",
"DoubleRedirectsInputFix" : "Corriger les doubles redirections",
"DoubleRedirectsInputDelete" : "Supprimer ces redirections",
"DoubleRedirectsInputAskDelete" : "Demander la suppression de ces redirections",
"DoubleRedirectsDeleteTemplate" : "{{Suppression Immédiate|raison=$reason|utilisateur=$user}}",
"DoubleRedirectsDeleteReason" : "Redirection cassée, inutile ou non pertinente",
"DoubleRedirectsFixSummary" : "Correction double redirection : [[$1]] → [[$2]]",
"DoubleRedirectsAskDeleteSummary" : "Demande de suppression immédiate ($1)",
"DoubleRedirectsDone_fix" : "Double redirection corrigée",
"DoubleRedirectsDone_delete" : "Redirection supprimée",
"DoubleRedirectsDone_askdeletion" : "Demande de suppression faite",
"Redirects" : "Redirections",
"WLHD_OnCategoryPageShowLinkText" : "[Afficher les pages liées]",
"WLHD_OnCategoryPageShowLinkTitle" : "Afficher les pages liées aux pages ci-dessous",
"WLHD_OnCategoryPageHideLinkText" : "[Masquer les pages liées]",
"WLHD_OnCategoryPageHideLinkTitle" : "Masquer les pages liées aux pages ci-dessous"
};
/* </syntaxhighlight>
== Groupes d'utilisateurs par action ==
<syntaxhighlight lang=javascript> */
window.WhatlinkshereDeluxe_MoveGroups = [ "autoconfirmed" ];
window.WhatlinkshereDeluxe_DeleteGroups = [ "sysop" ];
window.WhatlinkshereDeluxe_NukeGroups = [ "sysop" ];
/* </syntaxhighlight>
== Styles CSS ==
<gallery widths="50" heights="50">
Symbol_redirect_arrow_with_gradient.svg
Wikification2.png
Template_icon.svg
Farm-Fresh_photo_link.png
Yes_check.svg
Yes_check_rtl.svg
France_road_sign_A14.svg
</gallery>
<syntaxhighlight lang=javascript> */
mw.loader.addStyleTag("" +
".WhatlinkshereBLR { list-style-image: url('//upload.wikimedia.org/wikipedia/commons/thumb/7/71/Symbol_redirect_arrow_with_gradient.svg/15px-Symbol_redirect_arrow_with_gradient.svg.png'); } " +
".WhatlinkshereBLNR { list-style-image: url('//upload.wikimedia.org/wikipedia/commons/thumb/3/33/Wikification2.png/15px-Wikification2.png'); } " +
".WhatlinkshereEI { list-style-image: url('//upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Template_icon.svg/15px-Template_icon.svg.png'); } " +
".WhatlinkshereIU { list-style-image: url('//upload.wikimedia.org/wikipedia/commons/thumb/b/bb/Farm-Fresh_photo_link.png/11px-Farm-Fresh_photo_link.png'); } " +
".RecapContainer li { margin-left: 1em; } " +
".WhatlinkshereDeluxeList { -webkit-column-width: 350px;-moz-column-width: 350px;column-width: 350px;font-size:90%; } " +
"#CheckRedirectsForm .WhatlinkshereDeluxeList { -webkit-column-width:auto;-moz-column-width:auto;column-width:auto;font-size:90%; } " +
".WhatlinkshereDeluxeListLink { font-size:80%; } " +
".ActionButtons { margin-bottom:1em; } " +
".ActionButtons input { margin:0;padding:0; } " +
".ltr .DRC_done { background: url('//upload.wikimedia.org/wikipedia/commons/thumb/f/fb/Yes_check.svg/11px-Yes_check.svg.png') no-repeat scroll left center transparent;padding-left: 15px; } " +
".rtl .DRC_done { background: url('//upload.wikimedia.org/wikipedia/commons/thumb/6/62/Yes_check_rtl.svg/11px-Yes_check_rtl.svg.png') no-repeat scroll right center transparent;padding-right: 15px; } " +
".mw-special-Nuke .RecapContainer { list-style-image:url('//upload.wikimedia.org/wikipedia/commons/thumb/f/f4/France_road_sign_A14.svg/15px-France_road_sign_A14.svg.png'); } " +
".ns-14 .RecapContainer { font-size: 80%; } " +
".HideWhatLinksHere .RecapContainer { display:none; } "
);
/* </syntaxhighlight>
== Fonctions utilitaires ==
=== Vérification statut de pages (redirect ou lien rouge) ===
<syntaxhighlight lang=javascript> */
var PagesStatus = {};
var GetPagesStatus = function(titles, callback){
var api = new mw.Api();
api.get({action:'query', prop:'info', titles:titles}).then( function ( data ) {
if ( data.query.pages) {
var pages = data.query.pages;
for(var id in pages){
var thispage = pages[id];
var thispagetitle = thispage.title;
PagesStatus[thispagetitle] = [];
if(thispage.redirect === "") PagesStatus[thispagetitle].push("mw-redirect");
if(thispage.missing === "") PagesStatus[thispagetitle].push("new");
}
if(typeof(callback)==="function") callback();
}
});
};
var GetLinkClasses = function(Title){
var Classes = [];
var Status = PagesStatus[Title];
if(Status) Classes = Status;
return Classes;
};
/* </syntaxhighlight>
=== Détermination si l'utilisateur peut ou non faire une action ===
<syntaxhighlight lang=javascript> */
var UserCanMove = function(){
var Groups = mw.config.get('wgUserGroups');
if(!Groups) return false;
var MoveGroups = WhatlinkshereDeluxe_MoveGroups;
for(var a=0,l=MoveGroups.length;a<l;a++){
if(Groups.indexOf(MoveGroups[a]) !== -1) return true;
}
return false;
};
var UserCanDelete = function(){
var Groups = mw.config.get('wgUserGroups');
var DeleteGroups = WhatlinkshereDeluxe_DeleteGroups;
for(var a=0,l=DeleteGroups.length;a<l;a++){
if(Groups.indexOf(DeleteGroups[a]) !== -1) return true;
}
return false;
};
var UserCanNuke = function(){
var Groups = mw.config.get('wgUserGroups');
var NukeGroups = WhatlinkshereDeluxe_NukeGroups;
for(var a=0,l=NukeGroups.length;a<l;a++){
if(Groups.indexOf(NukeGroups[a]) !== -1) return true;
}
return false;
};
/* </syntaxhighlight>
=== anchorEncode() local ===
<syntaxhighlight lang=javascript> */
var LocalAnchorEncode = function(Text){
if(!Text) return "";
return encodeURIComponent(Text).replace(/%/g, ".");
};
/* </syntaxhighlight>
=== Récupération de la page cible ===
<syntaxhighlight lang=javascript> */
var GetRealPageTitle = function(){
var PageparamFromURL = mw.util.getParamValue('target');
if(PageparamFromURL !== null) return PageparamFromURL.replace(/_/g," ");
var PageLink, SpecialNS, ParamPage;
var MovePage = document.getElementById("movepage");
if(MovePage){
PageLink = MovePage.getElementsByTagName('a')[0];
if(PageLink) return PageLink.innerHTML;
}
var ContentSub = document.getElementById("contentSub");
if(!ContentSub) ContentSub = document.getElementById("contentSub2");
if(ContentSub){
PageLink = ContentSub.getElementsByTagName('a')[0];
if(PageLink){
SpecialNS = mw.config.get('wgFormattedNamespaces')["-1"] + ":";
ParamPage = PageLink.innerHTML.replace(new RegExp(SpecialNS + "[^\\/]*\\/"),"");
if(ParamPage.indexOf(SpecialNS) === -1) return ParamPage;
}
}
SpecialNS = mw.config.get('wgFormattedNamespaces')["-1"] + ":";
ParamPage = mw.config.get('wgPageName').replace(/_/g," ").replace(new RegExp(SpecialNS + "[^\\/]*\\/"),"");
if(ParamPage.indexOf(SpecialNS) === -1) return ParamPage;
};
/* </syntaxhighlight>
=== Creation d'un lien ===
<syntaxhighlight lang=javascript> */
var CreateLink = function(Args){
var Path = mw.config.get('wgServer') + ( Args.more ? mw.config.get('wgScript') + "?title=$1" : mw.config.get('wgArticlePath'));
var Link = '<a '
+ (typeof(Args.classes)=="object" && Args.classes.length > 0 ? 'class="'+Args.classes.join(" ")+'" ' : '')
+ (typeof(Args.target) != "undefined" ? 'target="'+Args.target+'" ' : '')
+ 'href="'+Path.split('$1').join(encodeURIComponent(Args.page)) + (Args.more ? Args.more : '') + '" '
+ 'title="'+(Args.title ? Args.title : Args.page )+'"'
+ '>'+(Args.text ? Args.text : Args.page )+'</a>';
return Link;
};
/* </syntaxhighlight>
=== Récupération de l'espace de noms d'une page ===
<syntaxhighlight lang=javascript> */
var GetPageNSNumber = function(Page){
var Found = false;
var NamespaceNumber = 0;
var AllNS = mw.config.get('wgFormattedNamespaces');
for(var NS in AllNS){
if(Found) continue;
var ThisNamespaceName = AllNS[NS];
if(ThisNamespaceName==="") continue;
var NamespaceNameRegExp = new RegExp("^"+ThisNamespaceName+":", "ig");
var Matches = Page.match(NamespaceNameRegExp);
if(Matches !== null && Matches.length == 1){
NamespaceNumber = parseInt(NS);
Page = Page.replace(NamespaceNameRegExp, "");
Found = true;
continue;
}
}
return NamespaceNumber;
};
/* </syntaxhighlight>
=== Récupération du titre de la page de discussion ===
<syntaxhighlight lang=javascript> */
var GetTalkPageTitle = function(Page){
var Found = false;
var NamespaceNumber = GetPageNSNumber(Page);
if(NamespaceNumber%2 !== 0) return false;
var Namespace = mw.config.get('wgFormattedNamespaces')[NamespaceNumber];
var TalkNamespace = mw.config.get('wgFormattedNamespaces')[(NamespaceNumber+1)];
if(!TalkNamespace) return false;
if(Namespace !== "") return (TalkNamespace + ":" + Page.replace(new RegExp("^"+Namespace+":"), ""));
return (TalkNamespace + ":" + Page);
};
/* </syntaxhighlight>
=== Récupération des les espaces de noms ciblés ===
<syntaxhighlight lang=javascript> */
var GetNamespaces = function(){
var NSparamFromURL = mw.util.getParamValue('namespace');
if( NSparamFromURL !== null) return NSparamFromURL;
var NS = [];
var NSNames = mw.config.get('wgFormattedNamespaces');
for(var nsnumber in NSNames){
if(!NSNames.hasOwnProperty(nsnumber)) continue;
var thisns = parseInt(nsnumber);
if(thisns>-1) NS.push(nsnumber);
}
return NS.join("|");
};
/* </syntaxhighlight>
=== Mise à jour liste de pages liées ===
<syntaxhighlight lang=javascript> */
var AddToSeeOnlyLink = function(SOtype, PageTitle, more){
var t = WhatlinkshereDeluxe_Texts[("WLH_SeeOnly_"+SOtype)];
return CreateLink({page:"Special:Whatlinkshere/"+PageTitle,title:t,text:t,more:more});
};
var ShowWhatlinkshereInLinkList = function(Args){
var Li = Args.li;
if(!Li) return;
var Container = Li;
if( !$(Container).hasClass("RecapContainer") ) Container = $(Li).find(".RecapContainer")[0];
if(!Container) return;
var PageTitle = Args.OPN;
var alwaysshowlist = Args.alwaysshowlist;
var texttype = (Args.texttype ? Args.texttype : "Short");
var types = [ "ALL", "BLR", "BLNR", "EI", "IU" ];
for(var a=0,l=types.length;a<l;a++){
var type = types[a];
var ThistypeContainer = $(Li).find(".Whatlinkshere"+type)[0];
if(!ThistypeContainer) continue;
var Count = 0;
try{ Count = PagesCount[PageTitle][type].length; }catch(e){ }
if(Count === 0 && type != "ALL" && !alwaysshowlist) ThistypeContainer.style.display = "none";
else if( type != "ALL") ThistypeContainer.style.display = "";
else if(Count !== 0) Container.style.display = "";
if(Count === 0 && !alwaysshowlist) continue;
var CountText = '<b>' + Count + '</b>';
var Text = WhatlinkshereDeluxe_Texts[("WhatLinksHere"+texttype+type+"_"+( Count===1 ? "One" : ( Count > 1 ? "Several" : "None")))];
Text = Text.split("$1").join(CountText);
if(typeof(Args.withlink) === "object" && Args.withlink.indexOf(type) !== -1){
var Classes = GetLinkClasses(PageTitle);
Text = Text.split("$2").join(CreateLink({page:PageTitle, classes:Classes}));
}else{
Text = Text.split("$2").join(PageTitle);
}
if(type === "ALL"){
if(mw.config.get('wgCanonicalSpecialPageName')=="Whatlinkshere"){
var SeeOnly = ( GetPageNSNumber(PageTitle) != 6 ? "WLH_SeeOnly_WithoutFile" : "WLH_SeeOnly_WithFile");
SeeOnly = WhatlinkshereDeluxe_Texts[SeeOnly];
SeeOnly = SeeOnly.split("$1").join(AddToSeeOnlyLink("EI", PageTitle, "&hidetrans=0&hidelinks=1&hideredirs=1&hideimages=1"));
SeeOnly = SeeOnly.split("$2").join(AddToSeeOnlyLink("BLNR", PageTitle, "&hidetrans=1&hidelinks=0&hideredirs=1&hideimages=1"));
SeeOnly = SeeOnly.split("$3").join(AddToSeeOnlyLink("BLR", PageTitle, "&hidetrans=1&hidelinks=1&hideredirs=0&hideimages=1"));
SeeOnly = SeeOnly.split("$4").join(AddToSeeOnlyLink("IU", PageTitle, "&hidetrans=1&hidelinks=1&hideredirs=1&hideimages=0"));
Text = Text.split("$3").join(SeeOnly);
}else{
var WLHlink = CreateLink({
target : '_blank',
page : 'Special:Whatlinkshere/'+PageTitle,
title : WhatlinkshereDeluxe_Texts["WhatLinksHereDetailsTitle"].split("$1").join(PageTitle),
text : WhatlinkshereDeluxe_Texts["WhatLinksHereDetailsText"]
});
Text = Text.split("$3").join(WLHlink);
}
}
ThistypeContainer.innerHTML = Text;
if(type != "ALL" && Count > 0){
CreateShowHideListLink(PageTitle, type, ThistypeContainer, alwaysshowlist);
}
}
if(typeof(Args.FunctionAfter) === "function") Args.FunctionAfter(Args);
};
var CreateShowHideListLink = function(PageTitle, type, TargetNode, showimmediately){
var LTR = $(document.body).hasClass("ltr");
var ListLink = document.createElement('a');
ListLink.className = "WhatlinkshereDeluxeListLink";
ListLink.title = WhatlinkshereDeluxe_Texts["ListLinkTitle"];
ListLink.innerHTML = WhatlinkshereDeluxe_Texts["ListLinkText"];
ListLink.href = "javascript:;";
ListLink.onclick = function(){
showhidePageList(this, PageTitle, type, LTR);
return false;
};
if(LTR){
TargetNode.appendChild(document.createTextNode(" "));
TargetNode.appendChild(ListLink);
}else{
TargetNode.insertBefore(document.createTextNode(" "), Span.firstChild);
TargetNode.insertBefore(ListLink, Span.firstChild);
}
if(showimmediately){
showhidePageList(ListLink, PageTitle, type, LTR);
ListLink.parentNode.removeChild(ListLink);
}
};
var showhidePageList = function(Link, page, type, LTR){
var ExistingList = document.getElementById("WhatlinkshereDeluxeList_"+LocalAnchorEncode(page)+"_"+type);
if(ExistingList){
if(ExistingList.style.display == "none") ExistingList.style.display = "";
else ExistingList.style.display = "none";
return;
}
var NewList = document.createElement('ol');
NewList.id = "WhatlinkshereDeluxeList_"+LocalAnchorEncode(page)+"_"+type;
NewList.className = "WhatlinkshereDeluxeList";
if(LTR){
Link.parentNode.insertBefore(NewList, Link.nextSibling);
}else{
Link.parentNode.insertBefore(NewList, Link);
}
var PageList = PagesCount[page][type];
for(var a=0,l=PageList.length;a<l;a++){
var Title = PageList[a];
var Li = document.createElement('li');
if( type === "BLR") Li.innerHTML = CreateLink({page:Title, classes:GetLinkClasses(Title), more:'&redirect=no'});
else Li.innerHTML = CreateLink({page:Title, classes:GetLinkClasses(Title)});
NewList.appendChild(Li);
}
};
/* </syntaxhighlight>
=== Recherche des pages liées ===
<syntaxhighlight lang=javascript> */
var PagesCount = {};
var AddPageToCount = function(page, type, title){
if(typeof(PagesCount[page])!=="object") PagesCount[page] = { "ALL":[], "BLR":[], "BLNR":[], "EI":[], "IU":[] };
if(typeof(PagesCount[page][type])!=="object") return false;
if( PagesCount[page][type].indexOf(title) ===-1 ){
PagesCount[page][type].push(title);
return true;
}
return false;
};
/* </syntaxhighlight>
==== Redirections et liens ====
<syntaxhighlight lang=javascript> */
var GetPageBL = function(Args){
if(!Args) Args = {};
var TitrePage = Args.PageName || GetRealPageTitle();
var APILimit = 499;
if((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) APILimit = 4999;
var queryopt = {
action: 'query',
list: 'backlinks',
bllimit: APILimit,
blnamespace: GetNamespaces(),
bltitle: TitrePage
};
if(Args.blfilterredir) queryopt.blfilterredir = Args.blfilterredir;
if(Args.RequeteContinue) queryopt.blcontinue = Args.RequeteContinue;
var api = new mw.Api();
api.get( queryopt ).then( function ( data ) {
if ( data.query.backlinks ) {
var page = Args.page;
var AllBL = data.query.backlinks;
var BL = AllBL.length;
var FoundRedirectToCheck = false;
for(var a=0,l=BL;a<l;a++){
var thispagetitle = AllBL[a].title;
AddPageToCount(page, "ALL", thispagetitle);
if(AllBL[a].redirect === ""){
var added = AddPageToCount(page, "BLR", thispagetitle);
if(added){
FoundRedirectToCheck = true;
var NewArgs = Args;
NewArgs.PageName = thispagetitle;
if(!PagesStatus[thispagetitle]) PagesStatus[thispagetitle] = [];
if(PagesStatus[thispagetitle].indexOf("mw-redirect") === -1)
PagesStatus[thispagetitle].push("mw-redirect");
if(NewArgs.RequeteContinue) delete NewArgs.RequeteContinue;
GetPageBL(NewArgs);
if(!Args.blfilterredir){
GetPageEI(NewArgs);
GetPageIU(NewArgs);
}
}
}else{
AddPageToCount(page, "BLNR", thispagetitle);
}
}
var MustContinue = data.continue;
if(MustContinue){
Args.RequeteContinue = MustContinue.blcontinue;
GetPageBL(Args);
}else if(!FoundRedirectToCheck){
if(typeof(Args.callback)==="function") Args.callback(Args);
}
}
} );
};
/* </syntaxhighlight>
==== Inclusions ====
<syntaxhighlight lang=javascript> */
var GetPageEI = function(Args){
if(!Args) Args = {};
var TitrePage = Args.PageName || GetRealPageTitle();
var APILimit = 499;
if((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) APILimit = 4999;
var queryopt = {
action: 'query',
list: 'embeddedin',
eilimit: APILimit,
einamespace: GetNamespaces(),
eititle: TitrePage
};
if(Args.RequeteContinue) queryopt.eicontinue = Args.RequeteContinue;
var api = new mw.Api();
api.get( queryopt ).then( function ( data ) {
if ( data.query.embeddedin ) {
var page = Args.page;
var AllEI = data.query.embeddedin;
var EI = AllEI.length;
for(var a=0,l=EI;a<l;a++){
var thispagetitle = AllEI[a].title;
AddPageToCount(page, "EI", thispagetitle);
AddPageToCount(page, "ALL", thispagetitle);
}
var MustContinue = data.continue;
if(MustContinue){
Args.RequeteContinue = MustContinue.eicontinue;
GetPageEI(Args);
}else{
if(typeof(Args.callback)==="function") Args.callback(Args);
}
}
} );
};
/* </syntaxhighlight>
==== Usage de fichier ====
<syntaxhighlight lang=javascript> */
var GetPageIU = function(Args){
if(!Args) Args = {};
var TitrePage = Args.PageName || GetRealPageTitle();
var APILimit = 499;
if((mw.config.get('wgUserGroups').indexOf("sysop")!=-1)||(mw.config.get('wgUserGroups').indexOf("bot")!=-1)) APILimit = 4999;
var queryopt = {
action: 'query',
list: 'imageusage',
iulimit: APILimit,
iunamespace: GetNamespaces(),
iutitle: TitrePage
};
if(Args.RequeteContinue) queryopt.iucontinue = Args.RequeteContinue;
var api = new mw.Api();
api.get( queryopt ).then( function ( data ) {
if ( data.query.imageusage ) {
var page = Args.page;
var AllIU = data.query.imageusage;
var IU = AllIU.length;
for(var a=0,l=IU;a<l;a++){
var thispagetitle = AllIU[a].title;
AddPageToCount(page, "IU", thispagetitle);
AddPageToCount(page, "ALL", thispagetitle);
}
var MustContinue = data.continue;
if(MustContinue){
Args.RequeteContinue = MustContinue.iucontinue;
GetPageEI(Args);
}else{
if(typeof(Args.callback)==="function") Args.callback(Args);
}
}
} );
};
/* </syntaxhighlight>
=== Après renommage ou suppression ===
==== Correction des doubles redirections ====
<syntaxhighlight lang=javascript> */
var CorrectRedirects_Run = function(Args){
var Page = Args.pagelist[Args.position];
if(!Page) return;
if(Args.position === 0){
Args.input.disabled = "disabled";
var Parent = Args.input.parentNode;
if(Args.type == "askdeletion") Parent.getElementsByTagName('input')[0].disabled = "disabled";
}
var URL = mw.config.get('wgServer')+mw.config.get('wgScript')+'?title='+encodeURIComponent(Page)+'&action=edit';
var RequestFunction = function(Aj) {
var Element = document.createElement('div');
document.body.insertBefore(Element, document.body.firstChild);
Element.style.display = "none";
Element.innerHTML = Aj.responseText;
var TexteFinal;
var SommaireFinal;
if(Args.type != "askdeletion"){
var AncienContenu = document.getElementById("wpTextbox1").value.split("\n");
AncienContenu[0] = "#REDIRECT[["+Args.newtitle+"]]";
TexteFinal = AncienContenu.join('\n');
SommaireFinal = WhatlinkshereDeluxe_Texts["DoubleRedirectsFixSummary"].split("$1").join(Args.oldtitle).split("$2").join(Args.newtitle);
}else{
var Template = WhatlinkshereDeluxe_Texts["DoubleRedirectsDeleteTemplate"];
Template = Template.split("$reason").join(WhatlinkshereDeluxe_Texts["DoubleRedirectsDeleteReason"]);
Template = Template.split("$user").join( mw.config.get('wgUserName') );
TexteFinal = Template;
SommaireFinal = WhatlinkshereDeluxe_Texts["DoubleRedirectsAskDeleteSummary"].split("$1").join(WhatlinkshereDeluxe_Texts["DoubleRedirectsDeleteReason"]);
}
var datas = {
"wpTextbox1" : TexteFinal,
"wpSection" : document.editform.wpSection.value,
"wpSummary" : SommaireFinal,
"wpMinoredit" : document.editform.wpMinoredit.value,
"wpStarttime" : document.editform.wpStarttime.value,
"wpEdittime" : document.editform.wpEdittime.value,
"wpEditToken" : document.editform.wpEditToken.value,
"wpSave" : "1"
};
var SubmitFunction = function(AjBis){
Element.parentNode.removeChild(Element);
DoubleRedirects_UpdateMarks(Args);
Args.position = (Args.position + 1);
CorrectRedirects_Run(Args);
};
$.ajax({
url : document.editform.action,
method : "POST",
headers : {'Content-Type':'application/x-www-form-urlencoded'},
data : datas,
complete : SubmitFunction
});
};
$.ajax({url:URL, complete: RequestFunction});
};
/* </syntaxhighlight>
==== Suppression des redirections ====
<syntaxhighlight lang=javascript> */
var DeleteRedirects_Run = function(Args){
var Input = Args.input;
var Page = Args.pagelist[Args.position];
if(!Page) return;
if(Args.position === 0){
var Parent = Input.parentNode;
var Inputs = Parent.getElementsByTagName('input');
for(var a=0,l=Inputs.length;a<l;a++) Inputs[a].disabled = "disabled";
}
var Tokendatas = {
action : 'query',
meta : 'tokens'
};
var apiToken = new mw.Api();
apiToken.get( Tokendatas ).then( function ( data ) {
try{
var Deletedatas = {
action : 'delete',
title : Page,
reason : WhatlinkshereDeluxe_Texts["DoubleRedirectsDeleteReason"],
watchlist : "nochange",
token : data.query.tokens.csrftoken
};
var apiDelete = new mw.Api();
apiDelete.post( Deletedatas, {'contentType':'application/x-www-form-urlencoded'} ).then( function ( data ) {
DoubleRedirects_UpdateMarks(Args);
Args.position = (Args.position + 1);
DeleteRedirects_Run(Args);
});
}catch(e){
alert("Problème token : "+Page);
}
});
};
/* </syntaxhighlight>
==== Marquage des pages traitées ====
<syntaxhighlight lang=javascript> */
var DoubleRedirects_UpdateMarks = function(Args){
var Page = Args.page;
var position = Args.position;
var OL = document.getElementById("WhatlinkshereDeluxeList_"+LocalAnchorEncode(Page)+"_BLR");
if(!OL) return;
var Li = OL.getElementsByTagName('li')[position];
if(!Li) return;
var Link = Li.getElementsByTagName('a')[0];
if(!Link) return;
var Classes = {"fix" : "mw-redirect", "delete" : "new", "askdeletion" : "" };
var NewClass = Classes[Args.type];
var Text = WhatlinkshereDeluxe_Texts[("DoubleRedirectsDone_"+Args.type)];
var Span = document.getElementById("DRC_"+Page+position);
if(!Span){
var LTR = $(document.body).hasClass("ltr");
Span = document.createElement('span');
Span.className = "DRC_done";
Span.id = "DRC_"+Page+position;
if(LTR){
Li.appendChild(document.createTextNode(" : "));
Li.appendChild(Span);
}else{
Li.insertBefore(document.createTextNode(" : "), Li.firstChild);
Li.insertBefore(Span, Li.firstChild);
}
}
Span.innerHTML = Text;
Link.className = NewClass;
};
/* </syntaxhighlight>
== Fonctions principales ==
=== [[Special:Whatlinkshere]] ===
<syntaxhighlight lang=javascript> */
var OnWhatlinkshere = function(){
var paragraphe = $('#mw-content-text').find('p')[0];
if(!paragraphe) return;
var TitrePage = GetRealPageTitle();
var NewDiv = document.createElement('div');
NewDiv.className = "RecapContainer";
var RecapText = ''
+ '<span class="WhatlinkshereALL">' + paragraphe.innerHTML + '</span>'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '<li style="display:none;" class="WhatlinkshereBLNR"></li>'
+ '<li style="display:none;" class="WhatlinkshereEI"></li>'
+ (GetPageNSNumber(TitrePage) == 6 ? '<li style="display:none;" class="WhatlinkshereIU"></li>':'')
+ '</ul>';
NewDiv.innerHTML = RecapText;
paragraphe.parentNode.insertBefore(NewDiv, paragraphe);
paragraphe.style.display = "none";
GetPagesStatus(TitrePage, function(){
var Args = {
page:TitrePage,
PageName:TitrePage,
OPN:TitrePage,
li:NewDiv,
texttype:"Long",
withlink:["ALL"],
callback:ShowWhatlinkshereInLinkList
};
GetPageBL(Args);
GetPageEI(Args);
if(GetPageNSNumber(TitrePage) == 6) GetPageIU(Args);
});
};
/* </syntaxhighlight>
=== Renommage ou suppression ===
<syntaxhighlight lang=javascript> */
var OnMoveOrDelete = function(){
var Form = document.getElementById('deleteconfirm');
if(!Form) Form = document.getElementById('mw-img-deleteconfirm');
if(!Form) Form = document.getElementById('movepage');
if(!Form) return;
var TitrePage = GetRealPageTitle();
var TalkPageTitle = GetTalkPageTitle(TitrePage);
var Recapitulatif = document.createElement('div');
var H = document.createElement("h2");
H.innerHTML = WhatlinkshereDeluxe_Texts["WhatLinksHere"];
Recapitulatif.appendChild(H);
var RecapS = document.createElement('div');
var RecapSText = ''
+ '<div class="RecapContainer">'
+ '<span class="WhatlinkshereALL"></span>'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '<li style="display:none;" class="WhatlinkshereBLNR"></li>'
+ '<li style="display:none;" class="WhatlinkshereEI"></li>'
+ (GetPageNSNumber(TitrePage) == 6 ? '<li style="display:none;" class="WhatlinkshereIU"></li>':'')
+ '</ul></div>';
RecapS.innerHTML = RecapSText;
Recapitulatif.appendChild(RecapS);
if(TalkPageTitle){
Recapitulatif.appendChild(document.createElement('hr'));
var RecapT = document.createElement('div');
var RecapTText = ''
+ '<div class="RecapContainer">'
+ '<span class="WhatlinkshereALL"></span>'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '<li style="display:none;" class="WhatlinkshereBLNR"></li>'
+ '<li style="display:none;" class="WhatlinkshereEI"></li>'
+ '</ul></div>';
RecapT.innerHTML = RecapTText;
Recapitulatif.appendChild(RecapT);
}
Form.parentNode.insertBefore(Recapitulatif, Form.nexSibling );
GetPagesStatus(( TalkPageTitle ? [TitrePage, TalkPageTitle] : TitrePage ), function(){
var ArgsS = {
page:TitrePage,
PageName:TitrePage,
OPN:TitrePage,
li:RecapS,
texttype:"Long",
withlink:["ALL"],
callback:ShowWhatlinkshereInLinkList
};
GetPageBL(ArgsS);
GetPageEI(ArgsS);
GetPageIU(ArgsS);
if(TalkPageTitle){
var ArgsT = {
page:TalkPageTitle,
PageName:TalkPageTitle,
OPN:TalkPageTitle,
li:RecapT,
texttype:"Long",
withlink:["ALL"],
callback:ShowWhatlinkshereInLinkList
};
GetPageBL(ArgsT);
GetPageEI(ArgsT);
}
});
};
/* </syntaxhighlight>
=== Vérification doubles redirections après renommage ===
<syntaxhighlight lang=javascript> */
var GetRedirectsAfterMove = function(){
var OldLink = document.getElementById("movepage-oldlink");
var NewLink = document.getElementById("movepage-newlink");
if(!OldLink || !NewLink) return;
var Content = document.getElementById('mw-content-text');
if(!Content) return;
var OldTitle = OldLink.title;
var OldTalkPageTitle = GetTalkPageTitle(OldTitle);
var NewTitle = NewLink.title;
var NewTalkPageTitle = GetTalkPageTitle(NewTitle);
var NewDiv = document.createElement('div');
NewDiv.id = "CheckRedirectsForm";
var Recapitulatif = document.createElement('div');
var H = document.createElement("h2");
var HelpLink = '<span style="font-size:50%">'+CreateLink({
target : '_blank',
page : WhatlinkshereDeluxe_Texts["DoubleRedirects_HelpPage"],
title : WhatlinkshereDeluxe_Texts["DoubleRedirects_HelpTitle"],
text : WhatlinkshereDeluxe_Texts["DoubleRedirects_HelpText"]
})+'</span>';
H.innerHTML = WhatlinkshereDeluxe_Texts["DoubleRedirects"].split("$1").join(HelpLink);
Recapitulatif.appendChild(H);
var RecapS = document.createElement('div');
var RecapSText = ''
+ '<div class="RecapContainer">'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '</ul>'
+ '</div>';
RecapS.innerHTML = RecapSText;
Recapitulatif.appendChild(RecapS);
if(OldTalkPageTitle){
Recapitulatif.appendChild(document.createElement('hr'));
var RecapT = document.createElement('div');
var RecapTText = ''
+ '<div class="RecapContainer">'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '</ul>'
+ '</div>';
RecapT.innerHTML = RecapTText;
Recapitulatif.appendChild(RecapT);
}
Content.appendChild(Recapitulatif);
GetPagesStatus( ( OldTalkPageTitle ? [OldTitle, OldTalkPageTitle] : OldTitle), function(){
GetPageBL({
page:OldTitle,
PageName:OldTitle,
OPN:OldTitle,
OldTitle:OldTitle,
NewTitle:NewTitle,
blfilterredir:"redirects",
li:RecapS,
texttype:"Long",
alwaysshowlist:true,
withlink:["BLR"],
callback:ShowWhatlinkshereInLinkList,
FunctionAfter:ShowCorrectDoubleRedirectsForm
});
if(OldTalkPageTitle){
GetPageBL({
page:OldTalkPageTitle,
PageName:OldTalkPageTitle,
OPN:OldTalkPageTitle,
OldTitle:OldTalkPageTitle,
NewTitle:NewTalkPageTitle,
blfilterredir:"redirects",
li:RecapT,
texttype:"Long",
alwaysshowlist:true,
withlink:["BLR"],
callback:ShowWhatlinkshereInLinkList,
FunctionAfter:ShowCorrectDoubleRedirectsForm
});
}
});
};
var ShowCorrectDoubleRedirectsForm = function(Args){
var Div = Args.li;
if(!Div) return;
var Page = Args.page;
var PageTitle = Args.OPN;
var OldTitle = Args.OldTitle;
var NewTitle = Args.NewTitle;
var Count = 0;
try{ Count = PagesCount[PageTitle]["BLR"].length; }catch(e){ }
if(Count === 0) return;
var ButtonsP = document.getElementById('ActionButtons'+LocalAnchorEncode(Page));
if(!ButtonsP){
ButtonsP = document.createElement('p');
ButtonsP.id = 'ActionButtons'+LocalAnchorEncode(Page);
ButtonsP.className = "ActionButtons";
Div.appendChild(ButtonsP);
}
ButtonsP.innerHTML = "";
var Buttons = [];
var FixButton = document.createElement('input');
FixButton.type = "button";
FixButton.value = WhatlinkshereDeluxe_Texts["DoubleRedirectsInputFix"];
FixButton.onclick = function(){ CorrectRedirects_Run({
type:"fix",
input:this,
pagelist:PagesCount[Page]["BLR"],
page:Page,
oldtitle:OldTitle,
newtitle:NewTitle,
askdeletion:false,
position:0
}); };
Buttons.push(FixButton);
if(UserCanDelete()){
var DeleteButton = document.createElement('input');
DeleteButton.type = "button";
DeleteButton.value = WhatlinkshereDeluxe_Texts["DoubleRedirectsInputDelete"];
DeleteButton.onclick = function(){ DeleteRedirects_Run({
type:"delete",
input:this,
pagelist:PagesCount[Page]["BLR"],
page:Page,
position:0
}); };
Buttons.push(DeleteButton);
}else{
var AskDeleteButton = document.createElement('input');
AskDeleteButton.type = "button";
AskDeleteButton.value = WhatlinkshereDeluxe_Texts["DoubleRedirectsInputAskDelete"];
AskDeleteButton.onclick = function(){ CorrectRedirects_Run({
type:"askdeletion",
input:this,
pagelist:PagesCount[Page]["BLR"],
page:Page,
position:0
}); };
Buttons.push(AskDeleteButton);
}
for(var a=0,l=Buttons.length;a<l;a++){
ButtonsP.appendChild(Buttons[a]);
}
};
/* </syntaxhighlight>
=== Vérification redirections après suppression ===
<syntaxhighlight lang=javascript> */
var GetRedirectsAfterDelete = function(){
var Form = document.getElementById('deleteconfirm');
if(!Form) Form = document.getElementById('mw-img-deleteconfirm');
if(Form) return; // delete not done yet
var Content = document.getElementById('mw-content-text');
if(!Content) return;
var TitrePage = GetRealPageTitle();
var H = document.createElement("h2");
H.innerHTML = WhatlinkshereDeluxe_Texts["Redirects"];
Content.appendChild(H);
var RecapS = document.createElement('div');
RecapS.id = "CheckRedirectsForm";
var RecapSText = ''
+ '<div class="RecapContainer">'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '</ul>'
+ '</div>';
RecapS.innerHTML = RecapSText;
Content.appendChild(RecapS);
GetPagesStatus( TitrePage, function(){
GetPageBL({
page:TitrePage,
PageName:TitrePage,
OPN:TitrePage,
blfilterredir:"redirects",
li:RecapS,
texttype:"Long",
alwaysshowlist:true,
withlink:["BLR"],
callback:ShowWhatlinkshereInLinkList,
FunctionAfter:ShowDeleteRedirectsForm
});
});
};
var ShowDeleteRedirectsForm = function(Args){
var Div = Args.li;
if(!Div) return;
var Page = Args.page;
var PageTitle = Args.OPN;
var OldTitle = Args.OldTitle;
var NewTitle = Args.NewTitle;
var Count = 0;
try{ Count = PagesCount[PageTitle]["BLR"].length; }catch(e){ }
if(Count === 0) return;
if(Count > 0){
var ButtonsP = document.getElementById('ActionButtons'+LocalAnchorEncode(Page));
if(!ButtonsP){
ButtonsP = document.createElement('p');
ButtonsP.id = 'ActionButtons'+LocalAnchorEncode(Page);
ButtonsP.className = "ActionButtons";
Div.appendChild(ButtonsP);
}
ButtonsP.innerHTML = "";
var DeleteButton = document.createElement('input');
DeleteButton.type = "button";
DeleteButton.value = WhatlinkshereDeluxe_Texts["DoubleRedirectsInputDelete"];
DeleteButton.onclick = function(){ DeleteRedirects_Run({
type:"delete",
input:this,
pagelist:PagesCount[Page]["BLR"],
page:Page,
position:0
}); };
ButtonsP.appendChild(DeleteButton);
}
};
/* </syntaxhighlight>
=== [[Special:Nuke]] ===
<syntaxhighlight lang=javascript> */
var OnNuke = function(){
var Form = false;
var Forms = document.getElementsByTagName('form');
if(!Forms[0]) return;
for(var a=0,l=Forms.length;a<l;a++){
if(Forms[a].name == "nukelist") Form = Forms[a];
}
if(!Form) return;
var PageList = Form.getElementsByTagName('ul')[0];
if(!PageList) return;
var Lis = PageList.getElementsByTagName('li');
for(var b=0,blen=Lis.length;b<blen;b++){
var Li = Lis[b];
var Link = Li.getElementsByTagName('a')[0];
if(!Link) continue;
var TitrePage = Link.title;
var Recapitulatif = document.createElement('ul');
Recapitulatif.className = "RecapContainer";
Recapitulatif.style.display = "none";
var RecapText = ''
+ '<li>'
+ '<span class="WhatlinkshereALL"></span>'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '<li style="display:none;" class="WhatlinkshereBLNR"></li>'
+ '<li style="display:none;" class="WhatlinkshereEI"></li>'
+ (GetPageNSNumber(TitrePage) == 6 ? '<li style="display:none;" class="WhatlinkshereIU"></li>':'')
+ '</ul>'
+ '</li>';
Recapitulatif.innerHTML = RecapText;
Li.appendChild(Recapitulatif);
var Args = {
page:TitrePage,
PageName:TitrePage,
OPN:TitrePage,
li:Li,
texttype:"Long",
callback:ShowWhatlinkshereInLinkList
};
GetPageBL(Args);
GetPageEI(Args);
if(GetPageNSNumber(TitrePage) == 6) GetPageIU(Args);
}
};
/* </syntaxhighlight>
=== Page de catégorie ===
<syntaxhighlight lang=javascript> */
var OnCategoryPage = function(){
var LTR = $(document.body).hasClass("ltr");
var ids = ["mw-pages", "mw-category-media"];
for(var a=0,l=ids.length;a<l;a++){
var ID = ids[a];
var container = document.getElementById(ID);
if(!container) continue;
var H = container.getElementsByTagName('h2')[0];
if(!H) continue;
var Link = document.createElement('a');
Link.id = ID + "_WLHlink";
Link.href = "javascript:;";
Link.style.fontSize = "60%";
Link.onclick = function(){ OnCategoryPage_Click(this.id); };
Link.innerHTML = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageHideLinkText"];
Link.title = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageHideLinkTitle"];
if(LTR){
H.appendChild(document.createTextNode(" "));
H.appendChild(Link);
}else{
H.insertBefore(document.createTextNode, H.firstSibling);
H.insertBefore(Link, H.firstSibling);
}
OnCategoryPage_Click(ID + "_WLHlink", WhatlinkshereDeluxe_PreloadOnCategoryPage);
}
};
var OnCategoryPage_Click = function(LinkID, loadWLH){
var launchlink = document.getElementById(LinkID);
if(!launchlink) return;
var contID = launchlink.id.split("_WLHlink").join("");
var RealContainer = OnCategoryPage_GetContainer(contID);
if(!RealContainer) return false;
if( $(RealContainer).hasClass("HideWhatLinksHere") ){
launchlink.innerHTML = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageHideLinkText"];
launchlink.title = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageHideLinkTitle"];
$(RealContainer).removeClass("HideWhatLinksHere");
}else{
launchlink.innerHTML = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageShowLinkText"];
launchlink.title = WhatlinkshereDeluxe_Texts["WLHD_OnCategoryPageShowLinkTitle"];
$(RealContainer).addClass("HideWhatLinksHere");
}
if(loadWLH !== false) OnCategoryPage_Run(contID);
return false;
}
var OnCategoryPage_GetContainer = function(ID){
var container = document.getElementById(ID);
if(!container) return false;
var RealContainer = $(container).find('div.mw-content-ltr')[0];
if(!RealContainer) RealContainer = $(container).find('div.mw-content-rtl')[0];
if(!RealContainer) return false;
return RealContainer;
}
var OnCategoryPageAlreadyDone = false;
var OnCategoryPage_Run = function(ID){
var RealContainer = OnCategoryPage_GetContainer(ID);
if(!RealContainer) return false;
if(OnCategoryPageAlreadyDone) return;
OnCategoryPageAlreadyDone = true;
var ThisGroupLinks = RealContainer.getElementsByTagName('a');
for(var g=0,glen=ThisGroupLinks.length;g<glen;g++){
var Link = ThisGroupLinks[g];
var Li = Link.parentNode;
var TitrePage = Link.title;
var Recapitulatif = document.createElement('ul');
Recapitulatif.className = "RecapContainer";
Recapitulatif.style.display = "none";
var RecapText = ''
+ '<li>'
+ '<span class="WhatlinkshereALL"></span>'
+ '<ul>'
+ '<li style="display:none;" class="WhatlinkshereBLR"></li>'
+ '<li style="display:none;" class="WhatlinkshereBLNR"></li>'
+ '<li style="display:none;" class="WhatlinkshereEI"></li>'
+ (GetPageNSNumber(TitrePage) == 6 ? '<li style="display:none;" class="WhatlinkshereIU"></li>':'')
+ '</ul>'
+ '</li>';
Recapitulatif.innerHTML = RecapText;
Li.appendChild(Recapitulatif);
var Args = {
page:TitrePage,
PageName:TitrePage,
OPN:TitrePage,
li:Link.parentNode,
texttype:"Short",
callback:ShowWhatlinkshereInLinkList
};
GetPageBL(Args);
GetPageEI(Args);
if(GetPageNSNumber(TitrePage) == 6) GetPageIU(Args);
}
};
/* </syntaxhighlight>
== Lancement ==
<syntaxhighlight lang=javascript> */
var LangModuleImplemented = false;
var CustomDone = false;
var Loading = function(func){
if(typeof(func)!=="function") return;
var Modules = ['mediawiki.api', 'mediawiki.util'];
var Lang = mw.config.get('wgUserLanguage');
if(Lang !== "fr"){
if(!LangModuleImplemented){
LangModuleImplemented = true;
var URL = '//fr.wikipedia.org/w/index.php?title=MediaWiki:Gadget-WhatlinkshereDeluxe.js/i18n/'+Lang+'.js&action=raw&ctype=text/javascript';
mw.loader.implement( "whatlinksheredeluxelang", [ URL ], {}, {}, {} );
}
Modules.push("whatlinksheredeluxelang");
}
mw.loader.using( Modules, function(){
$( document ).ready(function(){
if(!CustomDone){
CustomDone = true;
if( typeof(WhatlinkshereDeluxe_getLangCustom) === "function" ) try{ WhatlinkshereDeluxe_getLangCustom(); }catch(e){ }
if( typeof(WhatlinkshereDeluxe_getSiteCustom) === "function" ) try{ WhatlinkshereDeluxe_getSiteCustom(); }catch(e){ }
if( typeof(WhatlinkshereDeluxe_getUserCustom) === "function" ) try{ WhatlinkshereDeluxe_getUserCustom(); }catch(e){ }
}
func();
});
});
};
var LoadingCondition = {
"isDelete" : ( mw.config.get('wgAction') == "delete" && UserCanDelete() ),
"isMovePage" : ( mw.config.get('wgCanonicalSpecialPageName') == "Movepage" && UserCanMove() ),
"isWhatlinkshere" : ( mw.config.get('wgCanonicalSpecialPageName') == "Whatlinkshere" ),
"isNuke" : ( mw.config.get('wgCanonicalSpecialPageName') == "Nuke" && UserCanNuke() ),
"isCategoryPage" : ( mw.config.get('wgNamespaceNumber') == 14 && ["delete","history"].indexOf( mw.config.get('wgAction') ) === -1 )
};
if(LoadingCondition.isDelete){
Loading(OnMoveOrDelete);
Loading(GetRedirectsAfterDelete);
}
if(LoadingCondition.isMovePage){
Loading(OnMoveOrDelete);
Loading(GetRedirectsAfterMove);
}
if(LoadingCondition.isWhatlinkshere){
Loading(OnWhatlinkshere);
}
if(LoadingCondition.isNuke){
Loading(OnNuke);
}
if(LoadingCondition.isCategoryPage){
Loading(OnCategoryPage);
}
});
}
//</syntaxhighlight>