User:Awesome Aasim/rollbacknoleave.js

//                          if (!RBNL) { var RBNL = {}; $(document).ready(function {		$(".mw-rollback-link").click(function(e) { e.preventDefault; var link = $(this).find("a").attr("href"); //stack overflow: https://stackoverflow.com/questions/25203124/how-to-get-base-url-with-jquery-or-javascript var getUrl = window.location; var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1]; var urlparams = (new URL(baseUrl + link)).searchParams; var rollbackuser = urlparams.get('from'); var rollbacktoken = urlparams.get('token'); var rollbacktitle = urlparams.get('title'); $(this).html('                          '); var that = this; $.post(mw.config.get("wgScriptPath") + "/api.php", {				"action": "rollback",				"user": rollbackuser,				"token": rollbacktoken,				"title": rollbacktitle,				"format": "json"			}).done(function(result) {				console.log(result);				if (result.error) {					location.href = link;				} else {					$(that).html("Rollback complete");					$(that).off("click");				}			}).fail(function(result) {				location.href = link;			}); });	}); }