User:Benjaminthewill123123/rollback.js

// function warnUser(username, warntype, warnpage, rblink) { var addtext, reason; switch (warntype) { case "vandalism": addtext = "" + warnpage + ""; reason = "Warning user for vandalism"; break; default: return; }		$.post("/api.php", {action: "edit", title: "User talk:" + username, token: mw.user.tokens.values.editToken, appendtext: addtext, summary: reason}, function(data){			$.ajax( { url: rblink.attr("href"), success: function { window.location = "/wiki/" + wgPageName + "?action=purge"; console.log("Success!"); },				error: function { rblink.text( function ( i, val ) {						return val + ' [failed]';					} ); }			} );		}); } function rollbackLinks { baselink = $(".mw-rollback-link a")[0]; warntypes = {"vandalism": "V"}; for ( var i in warntypes ) { if ( warntypes.hasOwnProperty( i ) ) { $(baselink).after(' &bull; RB (' + warntypes[i] + ')'); }	} } $(function {	if ($("#mw-diff-ntitle2 .mw-rollback-link").length) {		rollbackLinks;		$(".mw-rollback-link a").click( function (event) { var $rblink = $( this ); var user = $rblink.attr( 'href' ).replace( /.*[&?]from=([^&]*).*/, '$1' ).replace( /\+/g, '_' ); if ($rblink.attr("warntype") != undefined && $rblink.attr("warntype") != null) { event.preventDefault; warnUser(user, $rblink.attr("warntype"), wgPageName, $rblink); console.log("Warned " + user); } else { window.location = $rblink.attr("href"); }		});	} });