User:Gryllida/js/deleteForUserPageSpam.js

/* Author : Svetlana Tkachenko svetlana@members.fsf.org Licence: GPLv3+ Description: [alpha] tab to do smart spam handling. Does NOT work. TODO: [ ] api to special:nuke [ ] option to hide revs in special:nuke See also . mw.loader.using(['mediawiki.api'], function {	"use strict";	/* 	== Quit if this is not user namespace ==	if (wgNamespaceNumber != 2)		return;	 */	// Add 'Userpage Spam' tab	var link = mw.util.addPortletLink(mw.config.get('skin') === 'vector' ? 'p-views' : 'p-cactions', 'javascript:void(0);', 'Broken Tab :P', 'p-gryllida-userpagespam', 'Delete user page spam', '6' );	var relevantUserName = mw.config.get( 'wgRelevantUserName' );	//alert(relevantUserName);	var spamtypes = {		'recurring userpage spam': 		{			desc: 'removes this user page with reason "recurring userpage spam"',			actions: [			// just delete the user page			api.postWithToken("delete", { action: 'delete', title: mw.config.get( 'wgPageName' ), reason: 'suspicious userpage spam' })			]		},		'phone numbers spam': {			desc: 'indef block, nuke/hiderevs missing, +blocknotice, +WN:List of phone number spambots',			actions: [				// indefinite block				api.postWithToken("block", { action: 'block', user: relevantUserName, reason: 'phone numbers spam' }),				// nuke all pages - could not find this				// hide revisions (hard; TODO?)				// add block notice to user page				api.postWithToken("edit", { action: 'edit', title: 'User:'+relevantUserName, text: '', // summary: 'added block notice (phone numbers spam)' }),				// add user to List of phone number spambots				api.postWithToken("edit", { action: 'edit', title: 'Wikinews:List of phone number spambots', text: '* --Gryllida 08:14, 28 February 2018 (UTC)', // summary: 'added new phone numbers spam bot' })			],		}	};	// Add event listener	//link.addEventListener('click', _showSpamTypeSelectUi); });