« MediaWiki:Gadget-RevertDiff.js » : différence entre les versions
Contenu supprimé Contenu ajouté
m Correction de redirection |
utilisation des liens directs plutôt que les redirections, subst de certains modèles devant l'être, ajout de la signature à la suite du message "Faut sourcer" |
||
Ligne 74 : | Ligne 74 : | ||
} else if (location.href.match(/warn=3/)) { |
} else if (location.href.match(/warn=3/)) { |
||
document.getElementById('wpSummary').value = 'Avertissement'; |
document.getElementById('wpSummary').value = 'Avertissement'; |
||
document.getElementById('wpTextbox1').value = '{{ |
document.getElementById('wpTextbox1').value = '{{subst:Test 2}} ~~'+'~~'; |
||
document.getElementById('editform').submit(); |
document.getElementById('editform').submit(); |
||
} else if (location.href.match(/warn=4/)) { |
} else if (location.href.match(/warn=4/)) { |
||
document.getElementById('wpSummary').value = 'Dernier avertissement'; |
document.getElementById('wpSummary').value = 'Dernier avertissement'; |
||
document.getElementById('wpTextbox1').value = '{{ |
document.getElementById('wpTextbox1').value = '{{subst:Test 3}} ~~'+'~~'; |
||
document.getElementById('editform').submit(); |
document.getElementById('editform').submit(); |
||
} else if (location.href.match(/warn=5/)) { |
} else if (location.href.match(/warn=5/)) { |
||
document.getElementById('wpSummary').value = ' |
document.getElementById('wpSummary').value = 'Seul avertissement'; |
||
document.getElementById('wpTextbox1').value = '{{ |
document.getElementById('wpTextbox1').value = '{{subst:Seul avertissement}} ~~'+'~~'; |
||
document.getElementById('editform').submit(); |
document.getElementById('editform').submit(); |
||
} else if (location.href.match(/warn=6/)) { |
} else if (location.href.match(/warn=6/)) { |
||
Ligne 88 : | Ligne 88 : | ||
document.getElementById('editform').submit(); |
document.getElementById('editform').submit(); |
||
} else if (location.href.match(/warn=7/)) { |
} else if (location.href.match(/warn=7/)) { |
||
document.getElementById('wpTextbox1').value = '{{subst:Faut sourcer}}'; |
document.getElementById('wpTextbox1').value = '{{subst:Faut sourcer}} ~~'+'~~'; |
||
document.getElementById('editform').submit(); |
document.getElementById('editform').submit(); |
||
} else if (location.href.match(/warn=8/)) { |
} else if (location.href.match(/warn=8/)) { |
Version du 1 mars 2013 à 07:28
/**
* Outils pour réverter
*
* fournit des liens dans les pages de diff pour révoquer facilement une modification et avertir son auteur
*
* Auteurs : Lorian (en), Chphe (fr)
* Dernière révision : 13 septembre 2012 pour le projet Aide et accueil
* {{Projet:JavaScript/Script|RevertDiff}}
*/
//<nowiki>
function getURLParameters(x) {
var questionMark = x.indexOf('?');
if (questionMark == -1) return {}
var fieldsArray = x.substr(questionMark + 1).split('&');
var fields = {}
for (var i = 0; i < fieldsArray.length; i++) {
var field = fieldsArray[i];
var equal = field.indexOf('=');
if (equal == -1) {
fields[decodeURIComponent(field)] = '';
} else {
fields[decodeURIComponent(field.substr(0, equal))] =
decodeURIComponent(field.substr(equal + 1));
}
}
return fields;
}
_GET = getURLParameters(location.href);
function getMessage (chemin, where, user1, user2) {
var message = prompt ('Quel message faut-il laisser ?', '');
if (message) {
window.location = chemin + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
}
addOnloadHook(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td');
if(user1.length == 0) return;
// Récupération du chemin vers la version à rétablir
var chemin = encodeURI(user1[0].getElementsByTagName('a')[1].href);
user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[2].innerHTML;
if (user2 == "défaire"){
user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
}
document.getElementById('contentSub').innerHTML = '(<a href="'+chemin+'&revert=1&user1='+user1+'&user2='+user2+'">Annuler</a> / <a href="javascript:var message = getMessage(\''+chemin+'\', \'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="'+chemin+'&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalisme</a> / <a href="javascript:var message = getMessage(\''+chemin+'\', \'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Avertir : <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=1">Maladresse</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=2">Vandalisme</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=3">Test2</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=4">Test3</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=5">Test4</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=6">Lien externe</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=7">Faut sourcer</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=8">Bienvenue</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=9">BienvenueIP</a> / <a href="//fr.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit§ion=new&warn=0">MerciIP</a>';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'Révocation des modifications de [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] (retour à la précédente version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']])';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'Révocation des modifications de [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] (retour à la précédente version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]) : '+_GET['message']+'';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'Révocation de vandalisme par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] (retour à la précédente version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']])';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'Révocation de vandalisme par [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] (retour à la précédente version de [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]) : '+_GET['message']+'';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpTextbox1').value = '{{subst:Test 0}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpTextbox1').value = '{{subst:Test 1}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'Avertissement';
document.getElementById('wpTextbox1').value = '{{subst:Test 2}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = 'Dernier avertissement';
document.getElementById('wpTextbox1').value = '{{subst:Test 3}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=5/)) {
document.getElementById('wpSummary').value = 'Seul avertissement';
document.getElementById('wpTextbox1').value = '{{subst:Seul avertissement}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=6/)) {
document.getElementById('wpTextbox1').value = '{{subst:Bienvenue spammeur}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=7/)) {
document.getElementById('wpTextbox1').value = '{{subst:Faut sourcer}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=8/)) {
document.getElementById('wpTextbox1').value = '{{Bienvenue nouveau|sign=~~~~}}';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=9/)) {
document.getElementById('wpTextbox1').value = '{{Bienvenue IP|sign=~~~~}}';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=0/)) {
document.getElementById('wpTextbox1').value = '{{Bienvenue IP méritante|sign=~~~~}}';
document.getElementById('editform').submit();
}
});
//</nowiki>