Jump to content

User:NguoiDungKhongDinhDanh/BlankThePage.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.
// Originally written by NhacNy2412.

$(function() {
	if (mw.config.get('wgNamespaceNumber') < 0) return;
	
	mw.loader.using(['mediawiki.util'],	function() {
		mw.util.addPortletLink('p-cactions', 'javascript:void(0)', 'Blank', 'ca-btp');
		$('#ca-btp').click(function() {
			(new mw.Api()).postWithToken('csrf', {
				action: 'edit',
				title: mw.config.get('wgPageName'),
				text: '',
				summary: 'Blanked the page using [[:m:User:NhacNy2412/BlankedThePage.js|BlankThePage.js]]'
			}).done(function() {
				location.reload();
			});
		});
	});
});