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.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* jshint esversion: 5, laxbreak: true, undef: true, eqnull: true, maxerr: 999 *//* globals console, window, $, mw */$.when(mw.loader.using(["mediawiki.api"]),$.ready).then(function(){varconfig=mw.config.get(['wgPageName','wgArticleId','wgNamespaceNumber']);if(config.wgNamespaceNumber!==0||config.wgArticleId===0){return;}varminMax=function(number,min,max){if(number<min){returnmin;}elseif(number>max){returnmax;}returnnumber;};config.hours=minMax(window.EWC_hours||24,2,72);varapi=newmw.Api({ajax:{headers:{"Api-User-Agent":"EditWarChecker ( https://en.wikipedia.org/wiki/User:Evad37/EditWarChecker )"}}});api.get({"action":"query","format":"json","prop":"revisions","titles":config.wgPageName,"rvprop":"ids|timestamp|flags|comment|user|tags|size","rvslots":"*","rvlimit":"max","rvend":newDate(Date.now()-config.hours*60*60*1000).toISOString()}).then(function(response){varrevertUsers={};varmaxUserReverts=0;functionaddRevert(user){if(revertUsers[user]){revertUsers[user]=revertUsers[user]++;}else{revertUsers[user]=1;}if(revertUsers[user]>maxUserReverts){maxUserReverts=revertUsers[user];}}varreverts=(response.query.pages[config.wgArticleId].revisions||[]).filter(function(revision,index,arr){// Edits tagged by systemif(revision.tags.includes("mw-undo")||revision.tags.includes("mw-rollback")){addRevert(revision.user);returntrue;}// Edits with undo/revert commentif(/(?:undo|undid|revert)/i.test(revision.comment)){addRevert(revision.user);returntrue;}// Edits with same kB change but opposite signsvarthisEditDiffSize=revision.size-(arr[index+1]?arr[index+1].size:NaN);varprevEditDiffSize=(arr[index+1]?arr[index+1].size:NaN)-(arr[index+2]?arr[index+2].size:NaN);varminDiffSize=10;// prevent false positives from minor copyeditsif(thisEditDiffSize&&prevEditDiffSize&&thisEditDiffSize>minDiffSize&&thisEditDiffSize===prevEditDiffSize*-1){addRevert(revision.user);returntrue;}returnfalse;});varrevertCount=reverts.length;varrevertUsersCount=Object.keys(revertUsers).length;varusersToList=$.map(revertUsers,function(reverts,user){returnreverts>3?user+" ("+reverts+")":null;}).join(", ");varmessage="Approximately "+revertCount+(revertCount===1?" revert":" reversions")+(revertUsersCount>0?" by "+revertUsersCount+(revertUsersCount===1?" user":" users"):"")+" in the last "+config.hours+" hours."+(usersToList?"\nUsers with 4+ reverts: "+usersToList:"");var$symbol=$("<img width='20' height='20' style='float:right;cursor:pointer;' title='Edit war checker'>");switch(true){// Grey (non-alert): No reverts, or single revertcaserevertCount<=1:$symbol.attr("src","https://upload.wikimedia.org/wikipedia/commons/e/e1/ButtonGray.svg");break;// Green alert: Everyone well within 3RR; not too many total revertscasemaxUserReverts<=2&&revertCount<=5:$symbol.attr("src","https://upload.wikimedia.org/wikipedia/commons/3/3c/ButtonGreen.svg");break;// Orange alert: One or more users at the 3RR limit; and/or quite a few revertscasemaxUserReverts<=3&&revertCount<=10:$symbol.attr("src","https://upload.wikimedia.org/wikipedia/commons/a/a6/ButtonOrange.svg");break;// Red alert: One or more users are passed the 3RR limit; and/or there are a lot of revertsdefault:$symbol.attr("src","https://upload.wikimedia.org/wikipedia/commons/9/97/ButtonRed.svg");break;}$symbol.click(function(){mw.notify(message,{title:"Edit war checker",tag:"editWarCheck"});});$('h1').append($symbol);}).catch(function(code,errorInfo){console.error("EditWarChecker error",errorInfo||code||"Unknown error");varmessage=errorInfo&&errorInfo.info||code.toString()||"Unknown error";mw.notify(message,{title:"EditWarChecker failed to load"});});});