MediaWiki:Gadget-Revert.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
// SCRIPT PER IL REVERT DI [[wikipedia:user:Lorian|Lorian]] TRADOTTO E RIADATTATO [[utente:wim b|Wim b]]
// Revert tools by Lorian<br />
//Riadattato per gli admin di wiktionary da [[utente:Wim_b|Wim b]]<br />
// VERSIONE PER ADMIN
//<pre><nowiki>
//FUNZIONI RISERVATE AI SYSOP
//Grazie [[w:utente:Salvatore_Ingala]]
function isSysop(){
if (mw.config.get('wgUserGroups'))
for(var i = 0; i < mw.config.get('wgUserGroups').length; i++)
if (mw.config.get('wgUserGroups')[i] == "sysop")
return true;
return false;
}
function getElementsByClass(searchClass,node,tag) {
// Function from http://www.dustindiaz.com/getelementsbyclass/
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
var _temp_get_arr_1 = new Array();
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
_temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
_GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
function getMessage (where, user1) {
var message = prompt ('Scrivi un messaggio nella cronologia', '');
window.location = '//it.wiktionary.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&message='+message;
}
$(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
var t='(<a href="//it.wiktionary.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'">Ripristina</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\');">Messaggio</a>) (<a href="//it.wiktionary.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'">Vandalismo</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\');">Messaggio</a>) (Avvisi: <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=1">Test</a> / <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=2">Vandalismo</a> / <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=3">Spam</a> / <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=4">WNF</a> / <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=5">WNB</a>/ <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=6">IP Vandalismo</a>/ <a href="//it.wiktionary.org/w/index.php?title=User_talk:'+user1+'&action=edit§ion=new&warn=7">Yc</a>)';
var regIP = /([0-9]+\.){3}[0-9]+/;
var isIP = regIP.test(user2);
if (isSysop()) {
t += ' (Admin: <a href="//it.wiktionary.org/wiki/Speciale:Blocca/'+user2+'">Blocca</a> / <a href="https://tools.wmflabs.org/guc/?user='+user2+'&blocks=true&lang=it">Interedits</a> / <a href="//it.wiktionary.org/w/index.php?title=Speciale%3ADeletedContributions&target='+user2+'">Contributi cancellati</a> / <a href="//it.wiktionary.org/w/index.php?title=' + _GET['title'] + '&action=protect">Proteggi</a> / <a href="//it.wiktionary.org/w/index.php?title=' + _GET['title'] + '&action=delete">Cancella</a> )';
if (isIP == true ) t += ' (IP: <a href="http://whois.domaintools.com/'+ user2 + '">Whois</a> / <a href="http://toolserver.org/~overlordq/cgi-bin/checktor.cgi?ip='+user2+'">TOR</a>)';
}
document.getElementById('contentSub').innerHTML =t;
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = 'Ripristinata la versione ' + _GET['oldid']+' di [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = 'Ripristinata la versione ' + _GET['oldid']+' di [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=1/)) {
document.getElementById('wpSummary').value = 'Ripristinata la versione ' + _GET['oldid']+' di [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] per vandalismo';
document.getElementById('editform').submit();
} else if (location.href.match(/vandalism=2/)) {
document.getElementById('wpSummary').value = 'Ripristinata la versione ' + _GET['oldid']+' di [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+') per vandalismo';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = 'Avviso test';
document.getElementById('wpTextbox1').value = '{{test}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = 'Avviso vandalismo';
document.getElementById('wpTextbox1').value = '{{vandalismo}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = 'spam';
document.getElementById('wpTextbox1').value = '{{Spam}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = 'WNF';
document.getElementById('wpTextbox1').value = '{{WNF}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=5/)) {
document.getElementById('wpSummary').value = 'WNB';
document.getElementById('wpTextbox1').value = '{{WNB}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=6/)) {
document.getElementById('wpSummary').value = 'IP Vandalismo';
document.getElementById('wpTextbox1').value = '{{IP Vandalismo}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=6/)) {
document.getElementById('wpSummary').value = 'Yc';
document.getElementById('wpTextbox1').value = '{{Yc|[[Utente:Krinkle|Krinkle]] <small>([[User talk:Krinkle|disc.]])</small> 22:23, 20 nov 2016 (CET)}}';
document.getElementById('editform').submit();
}
});