_ _    _ _____  ___   __                       
 __      _(_) | _(_)___ / ( _ ) / /_   ___ ___  _ __ ___  
 \ \ /\ / / | |/ / | |_ \ / _ \| '_ \ / __/ _ \| '_ ` _ \ 
  \ V  V /| |   <| |___) | (_) | (_) | (_| (_) | | | | | |
   \_/\_/ |_|_|\_\_|____/ \___/ \___(_)___\___/|_| |_| |_|

User:Writ Keeper/Scripts/massProtect.js

Nowadays, User:Writ Keeper/Scripts/massProtect.js is a topic that has captured the attention of people from all over the world. With its impact on society, economy and culture, User:Writ Keeper/Scripts/massProtect.js has generated growing interest in its study and analysis. From its historical origins to its relevance in the modern world, User:Writ Keeper/Scripts/massProtect.js has left a lasting mark on different aspects of everyday life. In this article, we will further explore the importance and influence of User:Writ Keeper/Scripts/massProtect.js, as well as its implications for the future.
function protectAllTheThings(protectLevel, editSummary)
{
	mw.loader.using('mediawiki.api').done(function ()
	{
		if (editSummary === null)
		{
			return false;
		}
		if (editSummary === '')
		{
			if(protectLevel == "all")
			{
				editSummary = "protection no longer necessary";
			}
			else
			{
				editSummary = "Mass protecting pages due to abuse";
			}
		}
		var api = new mw.Api();
		$(".mw-prefixindex-list a").each(function (ind, el)
		{
			api.postWithEditToken(
			{
				"action": "protect",
				"title": el.title,
				"protections": "edit=" + protectLevel,
				"expiry": "never",
				"reason": editSummary
			}
			).done(function ()
			{
				$(el).after("*");
			}
			);
		}
		);
	}
	);
	return false;
}
mw.hook('wikipage.content').add(function ()
{

	if (mw.config.get("wgCanonicalSpecialPageName") == "Prefixindex")
	{
		mw.loader.using().done(function ()
		{
			mw.util.addPortletLink('p-cactions', '#', "semiprotect all", "ca-semiprotecteverything", "semiprotect all pages displayed here");
			$("#ca-semiprotecteverything").click(function (event)
			{
				event.preventDefault();
				mw.loader.load('mediawiki.api');
				return protectAllTheThings("autoconfirmed", prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the semiprotection entirely)"));
			}
			);
			mw.util.addPortletLink('p-cactions', '#', "te-protect all", "ca-teprotecteverything", "te-protect all pages displayed here");
			$("#ca-teprotecteverything").click(function (event)
			{
				event.preventDefault();
				mw.loader.load('mediawiki.api');
				return protectAllTheThings("templateeditor", prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the te-protection entirely)"));
			}
			);
			mw.util.addPortletLink('p-cactions', '#', "unprotect all", "ca-unprotecteverything", "unprotect all pages displayed here");
			$("#ca-unprotecteverything").click(function (event)
			{
				event.preventDefault();
				mw.loader.load('mediawiki.api');
				return protectAllTheThings("all", prompt("Enter an edit summary, or leave blank to use the default (or hit Cancel to cancel the unprotection entirely)"));
			}
			);
		}
		);
	}
}
);