User:Gryllida/js/deleteForUserPageSpam.js
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences. — More skins
/*
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 <https://en.wikinews.org/wiki/User:Gryllida/Tasks>.
*/
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: '{{indefblocked|advertising/spam}}', //
summary: 'added block notice (phone numbers spam)'
}),
// add user to [[Wikinews:List of phone number spambots]]
api.postWithToken("edit", {
action: 'edit',
title: 'Wikinews:List of phone number spambots',
text: '* {{{{{1|u}}}|'+relevantUserName+'}} --[[User:Gryllida|Gryllida]] 08:14, 28 February 2018 (UTC)', //
summary: 'added new phone numbers spam bot'
})
],
}
};
// Add event listener
//link.addEventListener('click', _showSpamTypeSelectUi);
});