User:A930913/wave.js

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+" (WAVE)"; };

$.when(mw.loader.using('mediawiki.api'), $.ready).then(wave.load);

addEventListener("message", wave.listener, false);