User:Mike.lifeguard/globalBlockOptions.js

From Meta, a Wikimedia project coordination wiki

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function QuickGlobalBlock (expiryOther,blockReason,anonOnly) {
	globalBlockForm = document.forms[0];
	inputs = globalBlockForm.getElementsByTagName('input');
	for (i=0; i<inputs.length; i++) {
		if (inputs[i].name == 'wpExpiryOther') {
			inputs[i].value = expiryOther;
			continue;
		}
		if (inputs[i].name == 'wpReason') {
			inputs[i].value = blockReason;
			continue;
		}
		if (inputs[i].name == 'wpAnonOnly') {
			if (anonOnly==1) {
				inputs[i].checked = true;
			}
			else {
				inputs[i].checked = false;
			}
			continue;
		}
	}
	globalBlockForm.submit();
}

function addglobalblockoptions() {//expiryOther,blockReason,anonOnly
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("12 hours","cross-wiki spam",1)',
		'spam: 12h (ao)',
		'p-block-12h');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("6 hours","cross-wiki vandalism",0)',
		'vandal: 6h (hard)',
		'p-block-6h');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("31 hours","recent vandalism",1)',
		'vandal: 31h (AO)',
		'p-block-31h-ao');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("31 hours","recent vandalism",0)',
		'vandal: 31h (hard)',
		'p-block-31h');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("1 week","repeat vandalism",1)',
		'vandal: 1w',
		'p-block-week');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("1 month","chronic vandalism",1)',
		'vandal: 1m',
		'p-block-month');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("3 months","cross-wiki issues",0)',
		'xwiki: 3mo',
		'p-block-xwiki');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("6 months","abused [[w:Open proxy|proxy]] ([[m:WM:NOP|info]])",1)',
		'op (ao)',
		'p-block-proxy-ao');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickGlobalBlock+')("6 months","abused [[w:Open proxy|proxy]] ([[m:WM:NOP|info]])",0)',
		'op (hard)',
		'p-block-proxy');
	//expiryOther,blockReason,anonOnly
}
if ( wgCanonicalSpecialPageName == 'GlobalBlock' )addOnloadHook(addglobalblockoptions);