User:WHISKEY35/rbs.js

// function warnUser(username, warntype, warnpage) { $.getJSON("/api.php", {action: "query", prop: "info", titles: "User talk:" + username, intoken: "edit", format: "json", indexpageids: 1}, function(json) {		var pageid = json.query.pageids[0];		var tk = json.query.pages[pageid].edittoken;		var addtext, reason;		switch (warntype) {			case "vandalism":				addtext = "" + warnpage + "";				reason = "Warning user for vandalism";				break;			case "badedit":				addtext = "" + warnpage + "";				reason = "Warning user for a bad edit";				break;			case "ddd":				addtext = "~";				reason = "Warning user for COD:DDD violation";				break;			case "irl":				addtext = " ";				reason = "Warning user for addition of IRL info";				break;			default:				return;		}		$.post("/api.php", {action: "edit", title: "User talk:" + username, token: tk, appendtext: addtext, summary: reason}, function(data){});	}); } function rollbackLinks { baselink = $(".mw-rollback-link a")[0]; warntypes = {"vandalism": "V", "badedit": "BE", "ddd": "DDD", "irl": "IRL"}; for (var i in warntypes) { $(".mw-rollback-link").append(' | RB (' + warntypes[i] + ')'); $(".mw-rollback-link a").click( function (event) {			event.preventDefault;			var $rblink = $( this );			$.ajax( { url: $rblink.attr( 'href' ), success: function { console.log("Success!"); var	user = $rblink.attr( 'href' ).replace( /.*[&?]from=([^&]*).*/, '$1' ).replace( /\+/g, '_' ); console.log($rblink.attr("warntype")); if ($rblink.attr("warntype") != undefined && $rblink.attr("warntype") != null) { warnUser(user, $rblink.attr("warntype"), wgPageName); alert("Warned " + user); window.location.href = "/wiki/" + wgPageName + "?action=purge"; }				},				error: function { $rblink.text( function ( i, val ) {						return val + ' [failed]';					} ); }			} );		});	} } $(document).ready( function { if ($("#mw-diff-ntitle2 .mw-rollback-link").length) { rollbackLinks; } }); //