Jump to content

User:Writ Keeper/Scripts/oldSchoolThanks.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$(document).ready(function()
{
	$(".mw-thanks-thank-link").off("click");
	$(".mw-thanks-thank-link").click(function()
	{
		if((typeof noThanksConfirm != "undefined" && noThanksConfirm) || confirm("Are you sure you want to thank the author of this edit?"))
		{
			var clickedThanksLink = this;
			var postData = {rev : $(this).attr("data-revision-id"), token : mw.user.tokens.get( 'csrfToken' ), source : "script"};
			$.post("/w/api.php?action=thank&format=json", postData, function(){
				$(clickedThanksLink).replaceWith('<span class="mw-thanks-thanked">thanked</span>');
			});
		}
		return false;
	});
});