Wikibooks:Monobook.js/Revert.js

Wikibooks, manuali e libri di testo liberi.

//

// Revert tools by Lorian<br/>
//Riadattato per wikibooks da [[utente:Wim_b|Wim b]].<br/>
//Ringrazio [[w:Salvatore Ingala|Salvatore Ingala]] per aver <br/>
//aiutato nell'inserimento di una variabile per funzioni extra riservate agli admin<br/>
//<syntaxhighlight lang=javascript>

// _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, user2) {
var message = prompt ('Scrivi un messaggio nella cronologia', '');
window.location = 'http://it.wikibooks.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}

$(function (){
if (location.href.match(/diff=/)) {
// Get username of submitter
var user1 = getElementsByClass('diff-otitle','td',document); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
var user2 = getElementsByClass('diff-ntitle','td',document); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;

var t = '(<a href="http://it.wikibooks.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="http://it.wikibooks.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="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">Test</a> / <a href="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">Vandalismo</a> / <a href="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">Spam</a> / <a href="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">WNF</a> / <a href="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=5">WNB</a> / <a href="http://it.wikibooks.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=6">IP Vandalismo</a> )';

var regIP = /([0-9]+\.){3}[0-9]+/;
var isIP = regIP.test(user2);

if (isSysop()) {
t += ' (Sysop: <a href="http://it.wikibooks.org/wiki/Speciale:Blocca/'+user2+'">Blocca</a> / <a href="http://tools.wikimedia.de/~luxo/contributions/contributions.php?user='+user2+'&blocks=true&lang=it">Interedits</a> / <a href="http://it.wikibooks.org/w/index.php?title=Speciale%3ADeletedContributions&target='+user2+'">Contributi cancellati</a> / <a href="http://it.wikibooks.org/w/index.php?title=' + _GET['title'] + '&action=protect">Proteggi</a> / <a href="http://it.wikibooks.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://hemlock.ts.wikimedia.org/~krimpet/torcheck.php?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();
  }
});
//