User:Callum Fawsitt/global.js

importArticles({   type: 'script',    articles: [        'w:c:dev:TopEditors/code.js'    ] }); importScriptPage('User:Monchoman45/ChatHacks.js', 'c');

importScriptPage('User:Joeytje50/ChatPMs.js', 'c');

importScriptPage('User:Madnessfan34537/multikick.js', 'cod'); importArticles({ 	type: "script", 	articles: [ 		"u:dev:QuickModTools/loader.js" 	] }); /*	detect possible vandalism with alerts in chat request by Callum Fawsitt @author Penguin-Pal /* ============================== *\	# global objects \* ============================== */ ChatRC = {}; ChatRC.data = {}; ChatRC.fn = {}; /* ============================== *\	# data \* ============================== */ // list of read oldids ChatRC.data.ids = []; // alert title ChatRC.data.alertHeader = ' '; /* ============================== *\	# functions \* ============================== */ // load rc ChatRC.fn.load = function(fn) { $.getJSON("/api.php?action=query&format=json&list=recentchanges&rcprop=title|ids|sizes|user&rcshow=!bot&rclimit=80&rcnamespace=0&rcstart=&cb=" + new Date.getTime, function(data) {		var a = data.query.recentchanges;		window.a = a;		fn(a);	}); } // encode page title as uri ChatRC.fn.enc = function(s) { return s.replace(/ /g, "_").replace(/[^\/]/g, function(m) {		return encodeURIComponent(m);	}); } // encode text for html ChatRC.fn.encHTML = function(s) { var a = { "&": "amp", "<": "lt", ">": "gt" };	return s.replace(/&<>/g, function(m) {		return "&" + a[m] + ";";	}); } // check an individual revision ChatRC.fn.review = function(data) { if (ChatRC.data.ids.indexOf(data.rcid) == -1) { ChatRC.data.ids.push(data.rcid); var diff = data.newlen - data.oldlen; if (Math.abs(diff) >= 1000) { // change of more than 1000 bytes var message = '' + ChatRC.fn.encHTML(data.title) + ' &mdash;  0 ? "0c0" : diff < 0 ? "c00" : "aaa") + '" title="' + data.newlen.toLocaleString + ' bys after change">(' + (diff > 0 ? "+" : "") + String(diff.toLocaleString)+ ') &mdash; ' + ChatRC.fn.encHTML(data.user) + ''; return message; } else { return 0; }	}	console.info(data); } // insert message ChatRC.fn.insert = function(markup) { $(".Chat:first ul").append('\n\t' + markup + ''); } /* ============================== *\	# timeout \* ============================== */ ChatRC.to = setTimeout(function {	ChatRC.fn.load(function(data) { var messages = []; for (var i in data) { var currMessage = ChatRC.fn.review(data[i]); if (typeof currMessage === "string") { messages.push(currMessage); }		}		if (messages.length > 0) { ChatRC.fn.insert(ChatRC.data.alertHeader + '\n \n' + messages.join('\n \n')); }	}); }, 30000); /* ============================== *\	# css \* ============================== */ mw.util.addCSS(	'.inline-alert.chatrc-inline-alert + li .avatar {\n' +		'\tdisplay: inline;\n' +	'}\n' +	'.inline-alert.chatrc-inline-alert + li .time {\n' +		'\tdisplay: inline;\n' +	'}\n' +	'.inline-alert.chatrc-inline-alert + li .avatar.time.username {\n' +		'\tdisplay: block;\n' +	'}' );