Saltar para o conteúdo

Usuário:Contreiras45/Reversão e avisos.js

Origem: Wikipédia, a enciclopédia livre.

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.
/** Reversão e avisos ***********************************************************************
  *    Origem: [[Wikipedia:Software/Scripts/Reversão e avisos.js]]
  *     Ajuda: [[Wikipedia:Software/Scripts/Reversão e avisos]]
  * Descrição: Em páginas de comparação de 2 edições, inclui atalhos de reverter e avisar o usuário.
  *     Autor: [[:en:User:Lorian]] <noinclude>[[Categoria:!Código-fonte de scripts|Reversão e avisos]] [[en:Wikipedia:WikiProject User scripts/Scripts/Revert tools]]</noinclude>
  ********************************************************************************************/
 function getElementsByClass(searchClass,node,tag) {
  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;
 }
 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 ('Comentário a acrescentar ao sumário da reversão:', '');
  window.location = 'http://pt.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
 }
 addOnloadHook(function (){
  if (location.href.match(/diff=/)) {
    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;
    document.getElementById('contentSub').innerHTML = '(<a href="http://pt.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Reverter edição</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">+comentário</a>) (Usuário: <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">aviso</a> . <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=7">bem-vindo</a> . <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=6">IP</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">propaganda</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">mudou grafia</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">assinou artigo</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=5">VDA</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'Revertidas edições por [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']], para a última versão por [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'Revertidas edições por [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']], para a última versão por [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'Aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'Aviso propaganda';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Propaganda}}~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'Aviso ortografia';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Ortografia}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=4/)) {
    document.getElementById('wpSummary').value = 'Aviso-assinatura';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Aviso-assinatura}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=5/)) {
    document.getElementById('wpSummary').value = 'Aviso não copie';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Não copie}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=6/)) {
    document.getElementById('wpSummary').value = 'Bem-vindo IP + aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Bem-vindo IP}} {{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=7/)) {
    document.getElementById('wpSummary').value = 'Bem-vindo + aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Bem vindo}} {{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  }
 });/** Reversão e avisos ***********************************************************************
  *    Origem: [[Wikipedia:Software/Scripts/Reversão e avisos.js]]
  *     Ajuda: [[Wikipedia:Software/Scripts/Reversão e avisos]]
  * Descrição: Em páginas de comparação de 2 edições, inclui atalhos de reverter e avisar o usuário.
  *     Autor: [[:en:User:Lorian]] <noinclude>[[Categoria:!Código-fonte de scripts|Reversão e avisos]] [[en:Wikipedia:WikiProject User scripts/Scripts/Revert tools]]</noinclude>
  ********************************************************************************************/
 function getElementsByClass(searchClass,node,tag) {
  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;
 }
 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 ('Comentário a acrescentar ao sumário da reversão:', '');
  window.location = 'http://pt.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
 }
 addOnloadHook(function (){
  if (location.href.match(/diff=/)) {
    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;
    document.getElementById('contentSub').innerHTML = '(<a href="http://pt.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Reverter edição</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">+comentário</a>) (Usuário: <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">aviso</a> . <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=7">bem-vindo</a> . <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=6">IP</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">propaganda</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">mudou grafia</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">assinou artigo</a> / <a href="http://pt.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=5">VDA</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'Revertidas edições por [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']], para a última versão por [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'Revertidas edições por [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']], para a última versão por [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'Aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'Aviso propaganda';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Propaganda}}~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'Aviso ortografia';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Ortografia}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=4/)) {
    document.getElementById('wpSummary').value = 'Aviso-assinatura';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Aviso-assinatura}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=5/)) {
    document.getElementById('wpSummary').value = 'Aviso não copie';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Não copie}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=6/)) {
    document.getElementById('wpSummary').value = 'Bem-vindo IP + aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Bem-vindo IP}} {{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=7/)) {
    document.getElementById('wpSummary').value = 'Bem-vindo + aviso';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Bem vindo}} {{sub'+'st:Aviso}} ~~'+'~~';
    document.getElementById('editform').submit();
  }
 });