MediaWiki:Gadget-blockoptions.js
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.
/**
* Part of Gadget QuickBlockingTools
* Adds handy tabs at [[Special:Block]] with prefilled block reasons and settings.
* @update-token [[File:Gadget-blockoptions.js]]
*/
function QuickBlock (blockOther,blockReason,anonOnly,createAccount,AutoBlock,blockEmail,hideName,watchUser,allowUsertalk) {
blockForm = document.getElementById('blockip');
inputs = blockForm.getElementsByTagName('input');
for (i=0; i<inputs.length; i++) {
if (inputs[i].name == 'wpReason-other') {
inputs[i].value = Reason-other;
continue;
}
if (inputs[i].name == 'wpReason') {
inputs[i].value = Reason;
continue;
}
if (inputs[i].name == 'wpanonOnly') {
if (anonOnly==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpCreateAccount') {
if (createAccount==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpAutoBlock') {
if (autoBlock==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpblockEmail') {
if (blockEmail==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpHideName') {
if (hideName==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpWatchUser') {
if (watchUser==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
if (inputs[i].name == 'wpAllowUsertalk') {
if (allowUsertalk==1) {
inputs[i].checked = true;
}
else {
inputs[i].checked = false;
}
continue;
}
}
blockForm.submit();
}
function userIsInGroup (group) {
//are they in a given local group?
if (mw.config.get('wgUserGroups')) {
if (!group || group.length == 0) group = '*';
if (mw.config.get('wgUserGroups').join (' ').indexOf (group) != -1){
return true;
}
else{
return false;
}
}
return false;
}
function userIsInGlobalGroup (group) {
//are they in a given global group?
if (mw.config.get('wgGlobalGroups')) {
if (!group || group.length == 0) group = '*';
if (mw.config.get('wgGlobalGroups').join (' ').indexOf (group) != -1){
return true;
}
else{
return false;
}
}
return false;
}
function addblockoptions() {//blockOther,blockReason,anonOnly,createAccount,Autoblock,blockEmail,hideName,watchUser,allowUsertalk
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("31 hours","recent vandalism",1,1,1,0,0,0,1)',
'vandal: 31h',
'p-block-31h');
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("1 week","repeated vandalism",1,1,1,0,0,0,1)',
'vandal: 1w',
'p-block-week');
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("1 month","chronic vandalism",1,1,1,0,0,0,1)',
'vandal: 1m',
'p-block-month');
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("infinite","vandalism-only account",0,1,1,0,0,0,1)',
'vandal: indef',
'p-block-vandalism');
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("3 months","cross-wiki issues",0,1,1,0,0,0,0)',
'xwiki: 3mo',
'p-block-xwiki');
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("1 year","[[w:Open proxy|Open proxy]] or [[w:Zombie computer|zombie]] ([[m:WM:NOP|info]])",0,1,0,0,0,0,1)',
'op',
'p-block-proxy');
if(userIsInGroup('checkuser')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("infinite","checkuserblock",0,1,1,1,0,0,0)',
'checkuserblock-user',
'p-block-cu-user');
if(userIsInGroup('checkuser')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("1 year","checkuserblock",0,1,0,0,0,0,1)',
'checkuserblock-IP',
'p-block-cu-ip');
if(userIsInGroup('suppress')||userIsInGlobalGroup('steward')) mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("infinite","abusive user name",0,1,1,1,1,0,0)',
'invisible',
'p-block-invisible');
//blockOther,blockReason,anonOnly,createAccount,enableAutoblock,blockEmail,hideName,watchUser,allowUsertalk
}
if ( mw.config.get('wgCanonicalSpecialPageName') === 'Block' )
$.when($.ready, mw.loader.using('mediawiki.util')).then(addblockoptions);