/* This tool hits the RSS feed for recent changes every 30 seconds or so and checks for common vandalism. It does not make a separate server request for every edit. */ //


recent2={
	// Edit these to your liking.
	// Make sure there's a comma at the end of each line.
	badwordsUrl:          'User:Lupin/badwords',
	filterPage:           'User:Lupin/Filter_recent_changes',
	allRecentPage:        'User:Lupin/All_recent_changes',
	recentIPPage:         'User:Lupin/Recent_IP_edits',
	monitorWatchlistPage: 'User:Lupin/Monitor_my_watchlist',
	spelldictUrl:         'Wikipedia:Lists_of_common_misspellings/For_machines',
	spelldictPage:        'User:Lupin/Live_spellcheck',
	safePages:            '([Ww]ikipedia:([Ii]ntroduction|[Ss]andbox|[Tt]utorial[^/]*/sandbox)|[Tt]emplate:(X[1-9]|Template sandbox))',
	linkify:              true,
	updateSeconds:        30,
	ipUserRegex:          RegExp('(User:)?((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}' +
													'(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'),
	outputSeparator:      '
', templateNamespace: 'Template', namespaces: { 'Media':1, "Special":1, "User":1, "User talk":1, "Wikipedia":1, "Wikipedia talk":1, "Image":1, "Image talk":1, "MediaWiki":1, "MediaWiki talk":1, "Template":1, "Template talk":1, "Help":1, "Help talk":1, "Category":1, "Category talk":1, "Portal":1, "Portal talk":1 }, apiAulimitUser: 500, apiAulimitSysop: 5000, backgroundWindowsMax: 10, dummy: null // leave this last one alone }; recent2.download=function(bundle) { // mandatory: bundle.url // optional: bundle.onSuccess (xmlhttprequest, bundle) // optional: bundle.onFailure (xmlhttprequest, bundle) // optional: bundle.otherStuff OK too, passed to onSuccess and onFailure var x = window.XMLHttpRequest ? new XMLHttpRequest() : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false; if (x) { x.onreadystatechange=function() { x.readyState==4 && recent2.downloadComplete(x,bundle); }; x.open("GET",bundle.url,true); x.send(null); } return x; } recent2.downloadComplete=function(x,bundle) { x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true ) || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText)); }; if (! recent2.outputPosition) { recent2.outputPosition=''; } window.gettingBadWords=false; window.badWords=null; // paths if ( typeof(wgServer)!='string' || typeof(wgArticlePath)!='string' || typeof(wgScriptPath)!='string') { recent2.articlePath= 'http://' + document.location.hostname + '/wiki/'; recent2.scriptPath= 'http://' + document.location.hostname + '/w/'; } else { recent2.articlePath=wgServer+wgArticlePath.replace(/\$1/, ''); recent2.scriptPath=wgServer+wgScriptPath+'/'; } recent2.getBadWords=function() { window.gettingBadWords=true; recent2.download({ url: recent2.scriptPath + 'index.php?title=' + recent2.badwordsUrl + '&action=raw&ctype=text/css&max-age=7200', // reload every 2 h onSuccess: recent2.processBadWords, onFailure: function () { setTimeout(recent2.getBadWords, 15000); return true;}}); } window.diffCellRe=RegExp("\\+<\\/td>\\s*" + "]*>\\s*
\\s*(.*?)\\s*<\\/div>\\s*<\\/td>", 'gi'); // processBadWords: generate the badWords RegExp from // the downloaded data. // d is the xmlhttprequest object from the download recent2.processBadWords=function(d) { var data=d.responseText.split('\n'); var phrase=[]; var string=[]; for (var i=0; i (?: s=s.replace(/\(?!\?/g, '(?:'); // check that s represents a valid regexp try { var r=new RegExp(s); } catch (err) { var errDiv=newOutputDiv('recent2_error', recent2.outputPosition); errDiv.innerHTML='Warning: ignoring odd-looking regexp on line '+i +' of badwords:
' + s + '
'; continue; } if (isPhrase) phrase.push(s); else string.push(s); } else { // treat this line as a non-regexp and escape it. phrase.push(s.replace(RegExp('([-|.()\\+:!,?*^${}\\[\\]])', 'g'), '\\$1')); } } // 123 3 2|4 4|5 56 67 71 // ((( repeated char ) )|( ... | strings | ... )|( border )( ... | phrases | ... )( border )) window.badWords=RegExp("((([^\\-\\|\\{\\}\\].\\s'=wI:*#0-9a-f])\\3{2,})|(" + string.join('|') + ")|(^|[^/\\w])(" + phrase.join('|') + ")(?![/\\w]))", 'gi'); }; window.gettingWatchlist=false; recent2.watchlist=null; recent2.getWatchlist=function() { window.gettingWatchlist=true; recent2.download({url: recent2.articlePath + 'Special:Watchlist/raw', onSuccess: recent2.processWatchlist, onFailure: function () { setTimeout(getWatchlist, 15000); return true; }}); }; recent2.processWatchlist=function(req, bundle) { var watchlist={}; var lines=req.responseText.split('\n'); var inList=false; var article = ''; for (var i=0; i < lines.length; ++i) { if (inList || lines[i].indexOf('