Jump to content

User:Oshwah/QuickBlockScript.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.
//<nowiki>
$(function() {
	var namespace = mw.config.get('wgNamespaceNumber'),
	pageName = mw.config.get('wgPageName'),
	myUserName = mw.config.get('wgUserName'),
	targetUserName = mw.config.get('wgRelevantUserName'),
	blockTemplateName = "uw-block",
	blockTemplate = "{{subst:"+blockTemplateName+"|time=36 hours|sig=yes}}",
	blockReason = "[[WP:DE|Disruptive editing]]",
	blockSummary = "You have been blocked temporarily from editing for [[WP:Disruptive editing|abuse of editing privileges]].",
	api = new mw.Api();
	
	mw.loader.using( ['mediawiki.util'], function() {
		if([-1,0,2,3].indexOf(namespace) !== -1 && myUserName != targetUserName && targetUserName != null) {
			
			//ADD LINKS TO THE "MORE" MENU TO BE CLICKED ON, AND ADD BENEATH IT THE CLICK ACTIONS THAT FOLLOW.
			
			//SOCK BLOCK (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)', 
				'SOCK BLOCK (S)', 
				'aca-sockblock', 'Execute SOCK BLOCK on current user account with talk page notice.'
			);
			$('#aca-sockblock').on('click', function() {
				if (confirm('This script will block the user as a SOCK PUPPET ACCOUNT.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-sockblock').text('Please wait...');
					prepForBlock(1,0,0,1,'uw-sockblock','indefinite');
				}
			});
			
			//SOCK BLOCK (REVOKE TPA, EMAIL) (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)', 
				'SOCK BLOCK (NT, NE, S)', 
				'aca-sockblock-ntnes', 'Execute SOCK BLOCK on current user account, revoke talk page access and email, and with no talk page notice (SILENT).'
			);
			$('#aca-sockblock-ntnes').on('click', function() {
				if (confirm('This script will block the user as a SOCK PUPPET ACCOUNT and WITH EMAIL AND TPA REVOKED, and will NOT notify the user.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-sockblock-ntnes').text('Please wait...');
					prepForBlock(1,0,1,1,'uw-sockblock','indefinite');
				}
			});

			//{{CU}} SOCK BLOCK (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'{{CU}} SOCK BLOCK (S)', 
				'aca-cusockblock', 'Execute CHECKUSER BLOCK (indefinitely) on current account.'
			);
			$('#aca-cusockblock').on('click', function() {
				if (confirm('This script will CHECKUSER block the user as a SOCK PUPPET ACCOUNT, and will NOT notify the user.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-cusockblock').text('Please wait...');
					prepForBlock(2,0,0,1,'checkuserblock-account','indefinite');
				}
			});
			
			//{{CU}} SOCK BLOCK (REVOKE TPA, EMAIL) (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'{{CU}} SOCK BLOCK (NT, NE, S)',
				'aca-cusockblock-ntnes', 'Execute CHECKUSER BLOCK (indefinitely) on current account.'
			);
			$('#aca-cusockblock-ntnes').on('click', function() {
				if (confirm('This script will CHECKUSER block the user as a SOCK PUPPET ACCOUNT and WITH EMAIL AND TPA REVOKED, and will NOT notify the user.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-cusockblock-ntnes').text('Please wait...');
					prepForBlock(2,0,1,1,'checkuserblock-account','indefinite');
				}
			});
			
			//ABUSING MULTIPLE ACCOUNTS
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)', 
				'ABUSING MULTIPLE ACCOUNTS',
				'aca-abusingaccblock', 'Execute ABUSING MULTIPLE ACCOUNTS block on current user account.'
			);
			$('#aca-abusingaccblock').on('click', function() {
				if (confirm('This script will block the user as a ACCOUNT ABUSING OTHER ACCOUNTS and will NOT notify the user.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-abusingaccblock').text('Please wait...');
					prepForBlock(3,1,0,1,'uw-abusingaccblock','indefinite');
				}
			});
			
			//IP VANDALISM (36H)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'VANDALISM - IP / 36H', 
				'aca-ipvandalblock', 'Execute vandalism block (36 hours) on current user.'
			);
			$('#aca-ipvandalblock').on('click', function() {
				if (confirm('This script will block the user for VANDALISM for 36 HOURS.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-ipvandalblock').text('Please wait...');
					prepForBlock(4,1,0,0,'uw-vblock','36 hours');
				}
			});			
			
			//IP VANDALISM (36H - SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'VANDALISM - IP / 36H (S)', 
				'aca-ipvandalblocksilent', 'Execute vandalism block (36 hours) on current user, but do not leave a talk page notice (SILENT).'
			);
			$('#aca-ipvandalblocksilent').on('click', function() {
				if (confirm('This script will block the user for VANDALISM for 36 HOURS and WITHOUT leaving a block notice.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-ipvandalblocksilent').text('Please wait...');
					prepForBlock(4,0,0,0,'uw-vblock','36 hours');
				}
			});	

			//IP EVASION BLOCK (36H)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'EVASION BLOCK - IP (S)', 
				'aca-evadeblock', 'Execute EVASION BLOCK (36 hours) on current IP user, but do not leave a talk page notice (SILENT).'
			);
			$('#aca-evadeblock').on('click', function() {
				if (confirm('This script will block the IP for BLOCK EVASION  for 36 HOURS and WITHOUT leaving a block notice.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-evadeblock').text('Please wait...');
					prepForBlock(5,0,0,0,'Uw-ipevadeblock','36 hours');
				}
			});				
			
			//VANDALISM-ONLY ACCOUNT
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'VOA BLOCK', 
				'aca-voablock', 'Execute VOA block on current user account.'
			);
			$('#aca-voablock').on('click', function() {
				if (confirm('This script will apply a VOA BLOCK on the account.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-voablock').text('Please wait...');
					prepForBlock(6,1,0,0,'uw-voablock','indefinite');
				}
			});			
			
			//VANDALISM-ONLY ACCOUNT (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'VOA BLOCK (S)', 
				'aca-voablocksilent', 'Execute VOA block on current user account, but do not leave a talk page notice (SILENT).'
			);
			$('#aca-voablocksilent').on('click', function() {
				if (confirm('This script will apply a VOA BLOCK on the account and WITHOUT leaving a block notice.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-voablocksilent').text('Please wait...');
					prepForBlock(6,0,0,0,'uw-voablock','indefinite');
				}
			});

			//WP:NOTHERE
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'WP:NOTHERE Block', 
				'aca-nothereblock', 'Execute WP:NOTHERE block on current user account.'
			);
			$('#aca-nothereblock').on('click', function() {
				if (confirm('This script will apply a WP:NOTHERE BLOCK on the account.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-nothereblock').text('Please wait...');
					prepForBlock(7,1,0,0,'uw-nothereblock','indefinite');
				}
			});			
			
			//BLOCKED PROXY
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'{{blocked proxy}}', 
				'aca-proxyblock', 'Execute PROXY block (3 months) on current IP user (SILENT).'
			);
			$('#aca-proxyblock').on('click', function() {
				if (confirm('This script will block the IP as a PROXY for THREE MONTHS and WITHOUT leaving a block notice.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-proxyblock').text('Please wait...');
					prepForBlock(8,0,0,1,'uw-proxyblock','3 months');
				}
			});			
				
			//IP DISRUPTION (36H)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'DISRUPTION - IP / 36H', 
				'aca-disruptionblock', 'Execute disruptive editing block (36 hours) on current user.'
			);
			$('#aca-disruptionblock').on('click', function() {
				if (confirm('This script will block the user for DISRUPTIVE EDITING for 36 HOURS.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-disruptionblock').text('Please wait...');
					prepForBlock(9,1,0,0,'uw-disruptblock','36 hours');
				}
			});
			
			//UPOL BLOCK - SOFT
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'UPOL Block - Soft', 
				'aca-upolsoftblock', 'Execute UPOL soft block (IP auto-block disabled) on current user account.'
			);
			$('#aca-upolsoftblock').on('click', function() {
				if (confirm('This script will apply a soft block on the account per UPOL.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-upolsoftblock').text('Please wait...');
					prepForBlock(10,1,0,0,'Uw-ublock','indefinite');
				}
			});
			
			//UPOL BLOCK - HARD
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'UPOL Block - HARD', 
				'aca-upolhardblock', 'Execute UPOL HARD block on current user account.'
			);
			$('#aca-upolhardblock').on('click', function() {
				if (confirm('This script will apply a HARD BLOCK on the account per obvious UPOL.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-upolhardblock').text('Please wait...');
					prepForBlock(11,1,0,0,'Uw-uhblock','indefinite');
				}
			});
			
			//UPOL BLOCK - ABUSE (SILENT)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'UPOL Block - ABUSE', 
				'aca-upolabuseblock', 'Execute UPOL ABUSE block on current user (similar to \'UPOL Block - HARD\' but SILENT).'
			);
			$('#aca-upolabuseblock').on('click', function() {
				if (confirm('This will HARD BLOCK the username per LTA/ABUSIVE/LIBELOUS UPOL and LEAVE NO TEMPLATE OR NOTICE.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-upolabuseblock').text('Please wait...');
					prepForBlock(11,0,0,0,'Uw-uhblock','indefinite');
				}
			});			
			
			//UPOL BLOCK - VOA
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'UPOL Block - VOA', 
				'aca-upolvoablock', 'Execute UPOL and VOA ({{uw-vaublock}}) block on current user account.'
			);
			$('#aca-upolvoablock').on('click', function() {
				if (confirm('This will apply a block on the account as a UPOL violation that\'s ALSO a VOA.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-upolvoablock').text('Please wait...');
					prepForBlock(12,1,0,0,'uw-vaublock','indefinite');
				}
			});

			//PROMO BLOCK - SOFT
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'Promo Block - Soft', 
				'aca-promosoftblock', 'Execute promo soft block on current user account.'
			);
			$('#aca-promosoftblock').on('click', function() {
				if (confirm('This will apply a soft block on the account as a promotional username.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-promosoftblock').text('Please wait...');
					prepForBlock(13,1,0,0,'uw-softerblock','indefinite');
				}
			});
		
		//IF THE CURRENT PAGE IS A PAGE THAT CAN BE DELETED, EXECUTE THE FUNCTIONS TO SHOW THE OTHER "DELETE AND BLOCK" OPTIONS
		if([0,2,3].indexOf(namespace) !== -1 && myUserName != targetUserName && targetUserName != null) {
			
			//PROMO BLOCK - HARD
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'Promo Block - HARD', 
				'aca-promohardblock', 'Execute Promo HARD block on current user'
			);
			$('#aca-promohardblock').on('click', function() {
				if (confirm('This script delete the current page and apply a HARD BLOCK on the account as a promotional username with promotional edits.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-promohardblock').text('Please wait...');
					prepForBlock(14,1,0,0,'uw-spamublock','indefinite');
				}
			});
			
			//SPAM ADVERTISING ONLY ACCOUNT
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',
				'Spam / Ad-only Block', 
				'aca-soablock', 'Execute spam / advertising-only block on current user'
			);
			$('#aca-soablock').on('click', function() {
				if (confirm('This script will delete the current page and apply a BLOCK on the account as spam / advertising-only.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-soablock').text('Please wait...');
					prepForBlock(15,1,0,0,'uw-soablock','indefinite');
				}
			});
			
			////IF THE CURRENT PAGE IS A PAGE THAT CAN BE DELETED, EXECUTE THE FUNCTION TO SHOW THE "DELETE AND BLOCK" OPTION FOR SPAMBOT
			//if([2].indexOf(namespace) !== -1 && myUserName != targetUserName && targetUserName != null) {
			//SPAMBOT BLOCK
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'SPAMBOT', 
				'aca-spambotblock', 'Execute SPAMBOT block on current user.'
			);
			$('#aca-spambotblock').on('click', function() {
				if (confirm('This script will delete the page and block the user as a SPAMBOT and revoke TPA and leave NO NOTICE.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-spambotblock').text('Please wait...');
					prepForBlock(16,0,1,1,'uw-spamublock','indefinite');
				}
			});
			//}
		}
			//SPAMBOT BLOCK (CU)
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'{{CU}} SPAMBOT', 
				'aca-cuspambotblock', 'Execute CHECKUSER block on account as a confirmed SPAMBOT.'
			);
			$('#aca-cuspambotblock').on('click', function() {
				if (confirm('This script will block the user as a SPAMBOT and AS A CHECKUSER BLOCK, and will NOT notify the user.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-cuspambotblock').text('Please wait...');
					prepForBlock(17,0,1,1,'checkuserblock-account','indefinite');
				}
			});
			
			//U5 DELETION
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'U5 DELETION', 
				'aca-u5delete', 'Execute deletion per U5 on current page.'
			);
			$('#aca-u5delete').on('click', function() {
				if (confirm('This script will delete the current page per U5 and leave NO NOTICE.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-u5delete').text('Please wait...');
					//prepForBlock(19,'',''); This would normally be called, but since this is only deleting a page, we call the deletion function directly instead.
					deleteUserPageU5();
				}
			});
			
			//G11 DELETION
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'G11 DELETION', 
				'aca-g11delete', 'Execute deletion per G11 on current page.'
			);
			$('#aca-g11delete').on('click', function() {
				if (confirm('This script will delete the current page per G11 and leave NO NOTICE.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-g11delete').text('Please wait...');
					//prepForBlock(19,'',''); This would normally be called, but since this is only deleting a page, we call the deletion function directly instead.
					deleteUserPageG11();
				}
			});
			
			//G10 DELETION
			mw.util.addPortletLink(
				'p-cactions', 'javascript:void(0)',	
				'G10 DELETION', 
				'aca-g10delete', 'Execute deletion per G10 on current page.'
			);
			$('#aca-g10delete').on('click', function() {
				if (confirm('This script will delete the current page per G10 (ATTACK PAGE) and leave NO NOTICE.\n\nARE YOU SURE YOU WANT TO PROCEED?')) {
					$('#aca-g10delete').text('Please wait...');
					//prepForBlock(19,'',''); This would normally be called, but since this is only deleting a page, we call the deletion function directly instead.
					deleteUserPageG10();
				}
			});
		}
	});
	
	function prepForBlock(blockID,templateUser,revokeTalkAndEmail,overwriteExistingBlock,blockTemplateGivenName,blockDuration) {
		var blockDurationParameter = 'time='+blockDuration;
		if(blockDuration=='indefinite') {
			blockDurationParameter = 'indef=yes';
		}
		
		
		if(blockTemplateGivenName!='') {
			blockTemplateName = blockTemplateGivenName;
			blockTemplate = "{{subst:"+blockTemplateName+"|"+blockDurationParameter+"|sig=yes}}";
		}
		
		switch (blockID) {
			case 1:
				blockReason = '[[WP:BADSOCK|Sock puppetry]]';
				blockSummary = 'You have been blocked from editing for [[WP:BADSOCK|abusing multiple accounts]].';
				break;
			case 2:
				blockReason = '{{checkuserblock-account}} <!-- [[WP:BADSOCK|Sock puppetry]]. -->';
				blockSummary = 'You have been blocked from editing for [[WP:BADSOCK|abusing multiple accounts]].';
				break;
			case 3:
				blockReason = '[[WP:BADSOCK|Abusing multiple accounts]]';
				blockSummary = 'You have been blocked from editing for [[WP:BADSOCK|abusing multiple accounts]].';
				break;
			case 4:
				blockReason = '[[WP:Vandalism|Vandalism]]';
				blockSummary = 'You have been blocked from editing for persistent [[WP:Vandalism|vandalism]].';
				blockUserIP(templateUser,blockDuration);
				break;
			case 5:
				blockReason = '[[WP:EVADE|Block evasion]]';
				blockSummary = 'Anonymous users from this IP address have been blocked temporarily from editing for [[WP:EVADE|block evasion]].';
				blockUserIP(templateUser,blockDuration);
				break;
			case 6:
				blockReason = '[[WP:Vandalism-only account|Vandalism-only account]]';
				blockSummary = 'You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]].';
				break;
			case 7:
				blockReason = 'Clearly [[WP:NOTHERE|not here to contribute to the encyclopedia]]';
				blockSummary = 'You have been indefinitely blocked from editing because it appears that you are not here to [[WP:NOTHERE|build an encyclopedia]].';
				break;
			case 8:
				blockReason = '{{blocked proxy}}';
				//blockSummary = '';
				blockUserIPProxy();
				break;
			case 9:
				blockReason = '[[WP:Disruptive editing|Disruptive editing]]';
				blockSummary = 'You have been blocked from editing for [[WP:DE|disruptive editing]].';
				blockUserIP(templateUser,blockDuration);
				break;
			case 10:
				blockReason = '{{uw-ublock}} <!-- Username violation, soft block -->';
				blockSummary = 'Your account has been blocked from editing Wikipedia with this username because it does not meet our [[WP:UPOL|username policy]].';
				blockUserSoft(templateUser,blockDuration);
				break;
			case 11:
				blockReason = '{{uw-uhblock}} <!-- Username violation, hard block -->';
				blockSummary = 'Your account has been blocked indefinitely because the chosen username is a clear violation of our [[WP:UPOL|username policy]].';
				break;
			case 12:
				blockReason = '{{uw-vaublock}} <!-- Username violation, vandalism-only account -->';
				blockSummary = 'You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]] and your username is a blatant violation of the [[WP:UPOL|username policy]].';
				break;
			case 13:
				blockReason = '{{uw-softerblock}} <!-- Promotional username, soft block -->';
				blockSummary = 'You have been indefinitely blocked from editing because your [[WP:UPOL|username]] gives the impression that the account represents a group, organization or website.';
				blockUserSoft(templateUser,blockDuration);
				break;
			case 14:
				blockReason = '{{uw-spamublock}} <!-- Promotional username, promotional edits -->';
				blockSummary = 'You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam or advertising]] and your username is a violation of the [[WP:U|username policy]].';
				deleteUserPageG11();
				break;
			case 15:
				blockReason = '[[WP:Spam|Spam]] / [[WP:NOTADVERTISING|advertising]]-only account';
				blockSummary = 'You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam, advertising, or promotion]].';
				deleteUserPageG11();
				break;
			case 16:
				blockReason = 'Spambot.';
				//blockSummary = '';
				deleteUserPageG11();
				break;
			case 17:
				blockReason = '{{checkuserblock-account}} <!-- [[WP:SPAMBOT|Spambot]]. -->';
				//blockSummary = '';
				deleteUserPageG11();
				break;
			default:
				//TODO: CREATE DEFAULT CASE.
				break;
		}
		if (blockID != 4 && blockID != 5 && blockID != 8 && blockID !=9 && blockID != 10 && blockID != 13) {
			switch (overwriteExistingBlock) {
				case 0:
					switch (revokeTalkAndEmail) {
						case 0:
							blockUser(templateUser,blockDuration);
							break;
						case 1:
							blockUserNoTalkNoEmail(templateUser,blockDuration);
							break;
						default:
							blockUser(templateUser,blockDuration);
							break;
					}
					break;
				case 1:
					switch (revokeTalkAndEmail) {
						case 0:
							reblockUser(templateUser,blockDuration);
							break;
						case 1:
							reblockUserNoTalkNoEmail(templateUser,blockDuration);
							break;
						default:
							reblockUser(templateUser,blockDuration);
							break;
					}
					break;
				default:
					switch (revokeTalkAndEmail) {
						case 0:
							blockUser(templateUser,blockDuration);
							break;
						case 1:
							blockUserNoTalkNoEmail(templateUser,blockDuration);
							break;
						default:
							blockUser(templateUser,blockDuration);
							break;
					}
					break;
			}
		}
	}
  
	function blockUser(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			expiry: templateDuration,
			allowusertalk: true,
			noemail: false,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (account creation blocked) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function reblockUser(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			reblock: 1,
			expiry: templateDuration,
			allowusertalk: true,
			noemail: false,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (account creation blocked) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function blockUserSoft(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			expiry: templateDuration,
			allowusertalk: true,
			noemail: false,
			anononly: false,
			autoblock: false,
			nocreate: false,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (autoblock disabled) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function blockUserNoTalk(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			expiry: templateDuration,
			allowusertalk: false,
			noemail: false,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (account creation blocked, cannot edit own talk page) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}
  
	function blockUserNoTalkNoEmail(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			expiry: templateDuration,
			allowusertalk: false,
			noemail: true,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (account creation blocked, email disabled, cannot edit own talk page) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function reblockUserNoTalkNoEmail(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			reblock: 1,
			expiry: templateDuration,
			allowusertalk: false,
			noemail: true,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (account creation blocked, email disabled, cannot edit own talk page) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function blockUserIP(templateBool,templateDuration) {
		api.postWithToken("block", {
			action: 'block',
			expiry: templateDuration,
			allowusertalk: true,
			noemail: false,
			anononly: true,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (anon. only, account creation blocked) with an expiry time of "+templateDuration+" <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
			if(templateBool == 1) {
				addTemplateUserTalk();
			}
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function blockUserIPProxy() {
		api.postWithToken("block", {
			action: 'block',
			expiry: '3 months',
			allowusertalk: true,
			noemail: false,
			anononly: false,
			autoblock: true,
			nocreate: true,
			reason: blockReason,
			watchuser: false,
			user: targetUserName
		}).then(function(blockData) {
			$("#mw-content-text").append(
				"<p><b>Blocked</b> <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a> (anon. only, account creation blocked) with an expiry time of 3 months <i>(<span id='blocked-reason'></span>)</i></p>"
			);
			$('<span/>').text(blockReason).appendTo("#blocked-reason");
		}, function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> blocking <a href='"+mw.util.getUrl('User:'+targetUserName)+"'>"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}

	function deleteUserPageU5() {
		api.postWithToken("delete", {
			action: 'delete',
			reason: '[[WP:U5|U5]]: [[WP:NOTWEBHOST|Misuse of Wikipedia as a web host]]',
			watchlist: false,
			title: pageName
		}).then(function(deleteData) {
			$("#mw-content-text").append(
				"<p><b>Deleted</b> page <a href='"+mw.util.getUrl(pageName)+"'>"+pageName+"</a> <i>(<a href='"+mw.util.getUrl('WP:U5')+"'>U5</a>: <a href='"+mw.util.getUrl('WP:NOTWEBHOST')+"'>Misuse of Wikipedia as a web host</a>)</i></p>"
			);
		},function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> deleting page "+pageName+": "+error+"</p>"
			);
		});
	}
	
	function deleteUserPageG11() {
		api.postWithToken("delete", {
			action: 'delete',
			reason: '[[WP:G11|G11]]: Unambiguous [[Wikipedia:NOTADVERTISING|advertising]] or promotion',
			watchlist: false,
			title: pageName
		}).then(function(deleteData) {
			$("#mw-content-text").append(
				"<p><b>Deleted</b> page <a href='"+mw.util.getUrl(pageName)+"'>"+pageName+"</a> <i>(<a href='"+mw.util.getUrl('WP:G11')+"'>G11</a>: Unambiguous <a href='"+mw.util.getUrl('WP:NOTADVERTISING')+"'>advertising</a> or promotion)</i></p>"
			);
		},function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> deleting page "+pageName+": "+error+"</p>"
			);
		});
	}
  
	function deleteUserPageG10() {
		api.postWithToken("delete", {
			action: 'delete',
			reason: '[[WP:G10|G10]]: [[WP:ATP|Attack page]] or negative unsourced [[WP:BLP|BLP]]',
			watchlist: false,
			title: pageName
		}).then(function(deleteData) {
			$("#mw-content-text").append(
				"<p><b>Deleted</b> page <a href='"+mw.util.getUrl(pageName)+"'>"+pageName+"</a> <i>(<a href='"+mw.util.getUrl('WP:G10')+"'>G10</a>: <a href='"+mw.util.getUrl('WP:ATP')+"'>Attack page</a> or negative unsourced <a href='"+mw.util.getUrl('WP:BLP')+"'>BLP</a>)</i></p>"
			);
		},function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> deleting page "+pageName+": "+error+"</p>"
			);
		});
	}
  
	function addTemplateUserTalk() {
		var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
		d = new Date();

		api.postWithToken( "edit", {
			action: "edit",
			section: 'new',
			watchlist: "unwatch",
			sectiontitle: monthNames[d.getMonth()] + ' ' + d.getFullYear(),
			summary: blockSummary,
			text: "\n"+blockTemplate,
			title: "User talk:"+targetUserName
		}).then(function(editData) {
			$("#mw-content-text").append(
				"<p><b>Edited</b> <a href='"+mw.util.getUrl('User talk:'+targetUserName)+"'>User talk:"+targetUserName+"</a>: Created new section with template "+blockTemplateName+"</p>" +
				"<p><b>Complete (<a href='javascript:document.location.reload()'>reload</a>)</b></p>"
			);
		},function(error) {
			$("#mw-content-text").append(
				"<p><b>Error</b> editing <a href='"+mw.util.getUrl('User talk:'+targetUserName)+"'>User talk:"+targetUserName+"</a>: "+error+"</p>"
			);
		});
	}
});
//</nowiki>