Uit Hack42
Ga naar: navigatie, zoeken
(source: https://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-blockoptions.js&oldid=531178744)
 
(fixes)
Regel 1: Regel 1:
function QuickBlock (blockOther,blockReason,anonOnly,createAccount,enableAutoblock,emailBan,hideName,watchUser,allowUsertalk) {
+
// <nowiki>
blockForm = document.getElementById('blockip');
+
 
inputs = blockForm.getElementsByTagName('input');
+
function QuickBlock (blockOther,blockReason,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk) {
for (i=0; i<inputs.length; i++) {
+
blockForm = document.evaluate("//form[contains(@action,'Speciaal:Blokkeren')]", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (inputs[i].name == 'wpBlockOther') {
+
 
inputs[i].value = blockOther;
+
$( '#mw-input-wpExpiry' ).find( 'select' ).val(blockOther).change();
continue;
+
$( '#mw-input-wpReason' ).find( 'select' ).val("other").change();
}
+
$( 'input[name="wpReason-other"]' ).val(blockReason);
if (inputs[i].name == 'wpBlockReason') {
+
$( 'input[name="wpCreateAccount"]' ).prop( "checked", createAccount==1 );
inputs[i].value = blockReason;
+
$( 'input[name="wpDisableEmail"]' ).prop( "checked", emailBan==1 );
continue;
+
$( 'input[name="wpDisableUTEdit"]' ).prop( "checked", allowUsertalk==1 );
}
+
$( 'input[name="wpAutoBlock"]' ).prop( "checked", enableAutoblock==1 );
if (inputs[i].name == 'wpAnonOnly') {
+
$( 'input[name="wpWatch"]' ).prop( "checked", watchUser==1 );
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 == 'wpEnableAutoblock') {
 
if (enableAutoblock==1) {
 
inputs[i].checked = true;
 
}
 
else {
 
inputs[i].checked = false;
 
}
 
continue;
 
}
 
if (inputs[i].name == 'wpEmailBan') {
 
if (emailBan==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();
 
blockForm.submit();
 
}
 
}
Regel 105: Regel 43:
 
}
 
}
  
function addblockoptions() {//blockOther,blockReason,anonOnly,createAccount,enableAutoblock,emailBan,hideName,watchUser,allowUsertalk
+
function addblockoptions() {//blockOther,blockReason,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk
 
mw.util.addPortletLink('p-cactions',
 
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("31 hours","recent vandalism",0,1,0,0,0,0,1)',
+
'javascript:('+QuickBlock+')("infinite","spam",1,1,1,0,1)',
'vandal: 31h',
+
'spam: indef',
'p-block-31h');
+
'p-block-vandalism');
 
mw.util.addPortletLink('p-cactions',
 
mw.util.addPortletLink('p-cactions',
'javascript:('+QuickBlock+')("1 week","repeat vandalism",1,1,1,0,0,0,1)',
+
'javascript:('+QuickBlock+')("infinite","?",1,1,1,0,0)',
'vandal: 1w',
+
'?: indef',
'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');
 
'p-block-vandalism');
mw.util.addPortletLink('p-cactions',
+
//blockOther,blockReason,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk
'javascript:('+QuickBlock+')("3 months","cross-wiki issues",0,1,1,1,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,1,1,0,0,1)',
 
'checkuserblock-IP',
 
'p-block-cu-ip');
 
if(userIsInGroup('oversight')||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,emailBan,hideName,watchUser,allowUsertalk
 
 
}
 
}
if ( mw.config.get('wgCanonicalSpecialPageName') == 'Blockip' )$(addblockoptions);
+
if ( mw.config.get('wgCanonicalSpecialPageName') == 'Block' )$(addblockoptions);
 +
 
 +
// </nowiki>

Versie van 8 sep 2022 12:13

// <nowiki>

function QuickBlock (blockOther,blockReason,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk) {
	blockForm = document.evaluate("//form[contains(@action,'Speciaal:Blokkeren')]", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;

	$( '#mw-input-wpExpiry' ).find( 'select' ).val(blockOther).change();
	$( '#mw-input-wpReason' ).find( 'select' ).val("other").change();
	$( 'input[name="wpReason-other"]' ).val(blockReason);
	$( 'input[name="wpCreateAccount"]' ).prop( "checked", createAccount==1 );
	$( 'input[name="wpDisableEmail"]' ).prop( "checked", emailBan==1 );
	$( 'input[name="wpDisableUTEdit"]' ).prop( "checked", allowUsertalk==1 );
	$( 'input[name="wpAutoBlock"]' ).prop( "checked", enableAutoblock==1 );
	$( 'input[name="wpWatch"]' ).prop( "checked", watchUser==1 );

	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,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickBlock+')("infinite","spam",1,1,1,0,1)',
		'spam: indef',
		'p-block-vandalism');
	mw.util.addPortletLink('p-cactions',
		'javascript:('+QuickBlock+')("infinite","?",1,1,1,0,0)',
		'?: indef',
		'p-block-vandalism');
	//blockOther,blockReason,createAccount,enableAutoblock,emailBan,watchUser,allowUsertalk
}
if ( mw.config.get('wgCanonicalSpecialPageName') == 'Block' )$(addblockoptions);

// </nowiki>