User:A930913/wave.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:A930913/wave. |
mw.log.warn( 'You installed [[User:A930913/wave.js]], but it is no longer working\n'
+ 'Please remove the entry from your userscripts.');
/* Web Anti Vandal Engine (WAVE) */
wave={};
wave.load=function(){
if(mw.config.get('wgTitle')=="A930913/wave/run"){
$('html').load("//en.wikipedia.org/wiki/User:A930913/wave/splash");
}
};
wave.listener=function (event){
if ( event.origin !== "http://tools.wmflabs.org" && event.origin !== "https://tools.wmflabs.org" ) {
return;
}
var msg=JSON.parse(event.data);
var vandal=$("#mw-diff-ntitle2").find("a.mw-userlink").text();
switch(msg.action){
case "vandal":
wave.summary(msg.summary || "Vandalism");
Twinkle.fluff.revert('vand', vandal);
break;
case "diff":
$('html').load("//en.wikipedia.org/w/index.php?diff="+msg.diff);
break;
case "page":
$('html').load("//en.wikipedia.org/w/index.php?diff=cur&oldid=prev&title="+msg.title);
break;
case "prev":
$('html').load("//en.wikipedia.org"+$("#differences-prevlink").attr("href"));
break;
case "next":
$('html').load("//en.wikipedia.org"+$("#differences-nextlink").attr("href"));
break;
case "thank":
(new mw.Api()).postWithToken({
'action': 'thank',
'rev': /\/w\/index.php\?title=.+&oldid=(\d+)/.exec($("#mw-diff-ntitle1 a:first").attr("href"))[1],
'source': 'WAVE',
}).fail(function(errorCode, details) {
switch (errorCode) {
case 'invalidrevision':
alert(mw.msg('thanks-error-invalidrevision'));
break;
case 'ratelimited':
alert(mw.msg('thanks-error-ratelimited'));
break;
default:
alert(mw.msg('thanks-error-undefined'));
}
});
break;
default:
console.log("WAVE - Unknown action: "+event.data.action);
}
};
wave.summary=function(txt){
Twinkle.defaultConfig.twinkle.summaryAd=" "+txt+" ([[User:A930913/wave|WAVE]])";
};
$.when(mw.loader.using('mediawiki.api'), $.ready).then(wave.load);
addEventListener("message", wave.listener, false);