User:SilverLocust/sandbox.js

This is an old revision of this page, as edited by SilverLocust (talk | contribs) at 23:17, 11 February 2025 (Restored revision 1275181450 by SilverLocust (talk): Not working). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
$(".protect-button").on('click', function(e) {
	e.preventDefault();
	var page = this.innerText,
		message = 'Protect ' + page + '?',
		params = {
			action: 'protect',
			title: page,
			protections: 'edit=extendedconfirmed|move=extendedconfirmed',
			expiry: 'infinite',
			reason: '[[WP:ARBECR|Arbitration enforcement]]: [[WP:PIA]]',
			format: 'json'
		};
	if(confirm(message)) {
		api = new mw.Api();
		api.postWithToken( 'csrf', params );
	}
});