Usuário:HyperBroad/reversion.js
Aspeto
Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
//<pre>
//Fuente: http://en.wikipedia.org/wiki/Usuario:Lorian/monobook.js
//Personalizada por Axxgreazz, para el [[w:es:User:Axxgreazz/Monobook-Suite]]
//http://es.wikipedia.org/wiki/Usuario:Axxgreazz/Monobook-Suite
var Reve = 'Reverter';
var Mess = 'Mensagem';
var Warn = 'Aviso';
var Warn1 = 'Teste';
var Warn2 = 'Sem sentido';
var Warn3 = 'Branqueio';
var Warn4 = 'Pare';
var Warn5 = 'Último';
var Warn6 = 'Bloqueado';
var WarnSummary = 'Aviso com';
var RevertSummary1 = 'Revertidas edições por';
var RevertSummary2 = 'para a última versão';
var RevertSummary3 = 'por';
var RevertSummary4 = 'com';
// Revert tools
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, user2, oldid) {
var message = prompt (msStringU('Message') + ':', '');
window.location = 'http://'+ location.hostname + '/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + oldid + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
$(function ()
{
if (msValidarLN()) return;
if (typeof ms_Activa_Reversion == 'undefined') { ms_Activa_Reversion = true;}
if (!ms_Activa_Reversion) return;
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');
if (user2[0].getElementsByTagName('a')[2].href.indexOf ('undo=') != -1)
{ user2 = user2[0].getElementsByTagName('a')[3].innerHTML; }
else
{ user2 = user2[0].getElementsByTagName('a')[2].innerHTML; }
var oldid = getElementsByClass('diff-otitle',null,'td');
oldid = oldid[0].getElementsByTagName('a')[0].href.split("oldid=")[1];
document.getElementById('contentSub').innerHTML = '(<a href="http://'+ location.hostname + '/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + oldid + '&revert=1&user1='+user1+'&user2='+user2+'">' + msStringU(Reve) + '</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\', \''+oldid+'\');">' + msStringU(Mess) + '</a>) (' + msStringU(Warn) + ': <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=1">'+ msStringU(Warn1) + '</a> / <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=2">'+ msStringU(Warn2) + '</a> / <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=3">'+ msStringU(Warn3) + '</a> / <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=4">'+ msStringU(Warn4) + '</a> / <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=5">'+ msStringU(Warn5) + '</a> / <a href="http://'+ location.hostname + '/w/index.php?title=User_talk:'+user2+'&action=edit&warn=6">'+ msStringU(Warn6) + '</a>)';
} else if (location.href.match(/revert=1/)) {
document.getElementById('wpSummary').value = msStringU(RevertSummary1) + ' ' + '[[User:' + _GET['user2'] + '|' + _GET['user2'] + ']]' + ' ' + msStringU(RevertSummary2) + ' ' + msStringU(RevertSummary3) + ' ' + '[[User:' + _GET['user1'] + '|' + _GET['user1'] + ']]' + ' ' + msStringU(RevertSummary4) + ' ' + msSummaryLink;
document.getElementById('editform').submit();
} else if (location.href.match(/revert=2/)) {
document.getElementById('wpSummary').value = msStringU(RevertSummary1) + ' ' + '[[User:' + _GET['user2'] + '|' + _GET['user2'] + ']]' + ' ' + msStringU(RevertSummary2) + ' ' + msStringU(RevertSummary3) + ' ' + '[[User:' + _GET['user1'] + '|' + _GET['user1'] + ']]' + ' ' + msStringU(RevertSummary4) + ' ' + msSummaryLink + ' (' + _GET['message'] + ')';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=1/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '{{sub'+'st:Usuário:Lijealso/aviso1}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=2/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '{{sub'+'st:Usuário:Lijealso/aviso2}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=3/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '{{sub'+'st:Usuário:Lijealso/aviso3}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=4/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '\n{{sub'+'st:Usuário:Lijealso/aviso4}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=5/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '\n\n{{sub'+'st:Usuário:Lijealso/aviso5}} ~~'+'~~';
document.getElementById('editform').submit();
} else if (location.href.match(/warn=6/)) {
document.getElementById('wpSummary').value = msStringU(WarnSummary) + ' ' + msSummaryLink;
document.getElementById('wpTextbox1').value = document.getElementById('wpTextbox1').value + '\n\n{{sub'+'st:Usuário:Lijealso/aviso6}} ~~'+'~~';
document.getElementById('editform').submit();
}
});
//</pre>