User:Writ Keeper/Scripts/watchlistToggle.js

Today, User:Writ Keeper/Scripts/watchlistToggle.js is a topic that has acquired unusual relevance in today's society. Whether due to its impact on popular culture, its influence on the global economy or its importance in the scientific field, User:Writ Keeper/Scripts/watchlistToggle.js has become a topic of interest for a wide spectrum of audiences. This is due, in part, to the speed with which news and information spreads in the digital age, which has allowed User:Writ Keeper/Scripts/watchlistToggle.js to feature prominently in everyday conversations. In this article, we will explore the different dimensions of User:Writ Keeper/Scripts/watchlistToggle.js and its impact on our daily lives, as well as the possible implications this could have in the future.
function removeWatchlistItem(element)
{
	mw.loader.using("mediawiki.api").done(function()
	{
		var pageTitle = $(element).siblings().find(".mw-changeslist-history").prop("title");
		var mwApi = new mw.Api();
		mwApi.unwatch(pageTitle).done(function() 
		{
			$(element).unbind("click");
			$(element).click(function ()
			{
				return addWatchlistItem(this);
			});
			$(element).text("add");
			$(element).attr("title","Re-add this item to your watchlist");
		});
	});
	return false;
}
function addWatchlistItem(element)
{
	var pageTitle = $(element).siblings().find(".mw-changeslist-history").prop("title");
	var mwApi = new mw.Api();
	mwApi.watch(pageTitle).done(function() 
	{
		$(element).unbind("click");
		$(element).click(function ()
		{
			return addWatchlistItem(this);
		});
		$(element).text("rem");
		$(element).attr("title","Remove this item from your watchlist");
	});
	return false;
}

$(document).ready( function()
{
	if(mw.config.get("wgCanonicalSpecialPageName") === "Watchlist")
	{
		$("li.mw-changeslist-edit .mw-changeslist-links").not(".mw-usertoollinks").each(function(ind, el){$(el).append("&nbsp;|&nbsp;<a class='watchlistToggle' title='Remove this item from your watchlist'>rem</a>")});
		$("a.watchlistToggle").click(function() 
		{
			return removeWatchlistItem(this);
		});
	}
});