Käyttäjä:Str4nd/vandaalityökalut.js

Wikipediasta
Siirry navigaatioon Siirry hakuun

Huomautus: Selaimen välimuisti pitää tyhjentää asetusten tallentamisen jälkeen, jotta muutokset tulisivat voimaan.

  • Firefox ja Safari: Napsauta Shift-näppäin pohjassa Päivitä, tai paina Ctrl-F5 tai Ctrl-R (⌘-R Macilla)
  • Google Chrome: Paina Ctrl-Shift-R (⌘-Shift-R Macilla)
  • Internet Explorer ja Edge: Napsauta Ctrl-näppäin pohjassa Päivitä tai paina Ctrl-F5
  • Opera: Paina Ctrl-F5.
/*
 **** Vandaalityökalut ****
  Työkalut sivujen palauttamiseen, roskaksi merkitsemiseen, käyttäjän varoitukseen.
  Tämän sivun keskusteluun saa laittaa palautetta, ominaisuuspyyntöjä yms.

 ** Ohjeet käyttöönnottoon **
  Lisää [[Toiminnot:Oma_sivu/monobook.js]]-tiedostoon seuraava:

document.write('<script type="text/javascript" src="' 
             + 'http://fi.wikipedia.org/w/index.php?title=K%C3%A4ytt%C3%A4j%C3%A4:'
             + 'Str4nd/vandaality%C3%B6kalut.js&action=raw&ctype=text/javascript&'
             + 'dontcountme=s"></script>');

 ** Muuta **
  Alkuperäisen työkalun tehnyt [[:en:User:Lorian|Lorian]].
    ([[:en:Wikipedia:WikiProject User scripts/Scripts/Revert tools]])

 ** Pikapäivitys **
  Pikapäivitys selaimen välimuistia varten:
    http://fi.wikipedia.org/w/index.php?title=K%C3%A4ytt%C3%A4j%C3%A4:Str4nd/vandaality%C3%B6kalut.js&action=raw&ctype=text/javascript&dontcountme=s
*/

/*<pre>*/
 
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) {
  var message = prompt ('Minkä viestin haluat jättää?', '');
  window.location = 'http://fi.wikipedia.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',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://fi.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">kumoa</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">viesti</a>) (<a href="http://fi.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">vandalismia</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">viesti</a>) (Varoita käyttäjää '+user2+': <a href="http://fi.wikipedia.org/w/index.php?title=Keskustelu_käyttäjästä:'+user2+'&action=edit&section=new&warn=1&article='+wgTitle+'">Test</a> / <a href="http://fi.wikipedia.org/w/index.php?title=Keskustelu_käyttäjästä:'+user2+'&action=edit&section=new&warn=2">Test2</a> / <a href="http://fi.wikipedia.org/w/index.php?title=Keskustelu_käyttäjästä:'+user2+'&action=edit&section=new&warn=3">Test7</a> / <a href="http://fi.wikipedia.org/w/index.php?title=Keskustelu_käyttäjästä:'+user2+'&action=edit&section=new&warn=4">Tyhjennys</a> / <a href="http://fi.wikipedia.org/w/index.php?title=Keskustelu_käyttäjästä:'+user2+'&action=edit&warn=5">Sotkemista</a>)';
 } else if (location.href.match(/rcid=/)) {
    document.getElementById('contentSub').innerHTML = '(<a href="http://fi.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&roskaa=1">roskaa</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'Käyttäjän [[Toiminnot:Muokkaukset/'+_GET['user2']+'|'+_GET['user2']+']] muokkaukset kumottiin ja sivu palautettiin käyttäjän [[Toiminnot:Muokkaukset/'+_GET['user1']+'|'+_GET['user1']+']] tekemään versioon ' + _GET['oldid']+'.';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'Käyttäjän [[Toiminnot:Muokkaukset/'+_GET['user2']+'|'+_GET['user2']+']] muokkaukset kumottiin ja sivu palautettiin käyttäjän [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] tekemään versioon ' + _GET['oldid']+' ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=1/)) {
    document.getElementById('wpSummary').value = 'Käyttäjän [[Toiminnot:Muokkaukset/'+_GET['user2']+'|'+_GET['user2']+']] vandalismi kumottiin ja sivu palautettiin käyttäjän [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] tekemään versioon ' + _GET['oldid']+'.';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=2/)) {
    document.getElementById('wpSummary').value = 'Käyttäjän [[Toiminnot:Muokkaukset/'+_GET['user2']+'|'+_GET['user2']+']] vandalismi kumottiin ja sivu palautettiin käyttäjän [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] tekemään versioon ' + _GET['oldid']+'. ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/roskaa=1/) && document.getElementById('wpTextbox1').value != "") {
    if (document.getElementById("wpTextbox1").value.match(/{{roskaa/) || document.getElementById("wpTextbox1").value.match(/{{Roskaa/)) {
      document.getElementById('contentSub').innerHTML = '<span style="color:red;font-weight:bold;font-size:120%">Ei merkitty roskaksi. Tämä artikkeli on jo roskana.</span>';
    } else {
      document.getElementById('wpSummary').value = 'Merkitty roskaksi.';
      document.getElementById('wpTextbox1').value = '{{roskaa}}'+document.getElementById('wpTextbox1').value;
      document.getElementById('editform').submit();
    }
  } else if (location.href.match(/warn=1/)) {
    if (_GET['article'] == 'Etusivu') { var article = ''; } else { var article = _GET['article']; }
    document.getElementById('wpSummary').value = 'Ensimmäinen huomautus';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:Test|'+article+'}} –~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'Varoitus vandalismista';
    document.getElementById('wpTextbox1').value += '{{sub'+'st:Test2}} –~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'Varoitus vakavasta vandalismista';
    document.getElementById('wpTextbox1').value += '{{sub'+'st:test7}} –~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=4/)) {
    document.getElementById('wpSummary').value = 'Artikkelisivun tyhjentäminen.';
    document.getElementById('wpTextbox1').value += '{{sub'+'st:Tyhjentäminen}} –~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=5/)) {
    document.getElementById('wpSummary').value = 'Sotkemista.';
    document.getElementById('wpTextbox1').value += '* Sotkemista. –~~'+'~~';
    document.getElementById('editform').submit();
  }
});
/*</pre>*/