User:Bosco/ProjectProtect.js

From Test Wiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// From https://zh.wikipedia.org/wiki/User:Xiplus/js/HRTProtectLink.js
// CC BY SA 4.0
// Forked from https://unbooks.miraheze.org/wiki/User:PB2008/ProjectProtect.js
mw.loader.load('//unbooks.miraheze.org/w/index.php?title=User:PB2008/ProjectProtect-en.js&bcache=1&maxage=259200&action=raw&ctype=text/javascript');
if (mw.config.get("wgNamespaceNumber") === 4) {
	mw.loader.using(['mediawiki.util']).done(function(){
		mw.util.addPortletLink(
			'p-cactions',
			mw.config.get("wgServer")+mw.config.get("wgScriptPath")+'/index.php?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=protect&mwProtect-level-edit=bureaucrat&mwProtect-level-move=bureaucrat&mwProtect-level-delete=bureaucrat&mwProtect-level-protect=bureaucrat&mwProtect-reason=Policy Page ([[User:PB2008/ProjectProtect.js|ProjectProtect.js]])',
			'Policy Page (Bcrat protection)'
		);
		mw.util.addPortletLink(
			'p-cactions',
			mw.config.get("wgServer")+mw.config.get("wgScriptPath")+'/index.php?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=protect&mwProtect-level-edit=steward&mwProtect-level-move=steward&mwProtect-level-delete=steward&mwProtect-level-protect=steward&mwProtect-reason=Policy Page ([[User:PB2008/ProjectProtect.js|ProjectProtect.js]])',
			'Policy Page (Steward protection)'
		);
	});
}