User:Maxim/rmuaa.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:Maxim/rmuaa. |
// test stuff for usernames
// derived from [[User:Legoktm/rescaled.js]]
if ( mw.config.get('wgNamespaceNumber') > 0 ) {
mw.loader.using( ['mediawiki.util', 'mediawiki.api'], function() {
var rmuaa_tab = mw.util.addPortletLink( 'p-cactions', '#',
'rmuaa', 'ca-rmuaa', 'rmuaa');
$( rmuaa_tab ).click( rm_uaa );
});
}
// rm_uaa function
function rm_uaa() {
var api = new mw.Api();
api.get( {
action: 'query',
prop: 'imageinfo|revisions',
titles: mw.config.get('wgPageName'),
iiprop: 'archivename',
iilimit: 'max',
rvprop: 'content',
rvlimit: '1'
}).done( function ( data ) {
var pgdata = data.query.pages[mw.config.get('wgArticleId')];
// Also edit!
var text = pgdata.revisions[0]['*'];
// from drilnoth's script
text = text.replace(/\n*<!-- THE FOLLOWING CATEGORY SHOULD BE REMOVED WHEN THE USER IS BLOCKED, OR IT IS DECIDED THE NAME DOES NOT APPEAR TO VIOLATE POLICY, OR THIS TEMPLATE HAS BEEN IN PLACE FOR A WHILE WITH NO ACTION: --> {{#ifeq:{{ROOTPAGENAME}}\|.*\|\[\[Category:Wikipedia usernames with possible policy issues\|{{PAGENAME}}]]}}/ig,'');
text = text.trim();
api.postWithToken( 'edit', {
action: 'edit',
title: mw.config.get('wgPageName'),
summary: 'Remove [[:Category:Wikipedia usernames with possible policy issues]] for inactive account',
text: text
}).done( function ( data ) {
mw.notify("Removed the category.");
});
var text2 = pgdata.revisions[0]['*'];
text2 = text2.replace(/\n*<!-- THE FOLLOWING TWO CATEGORIES \(down to \*\*\*\) SHOULD BE REMOVED WHEN THE USER IS BLOCKED, OR IT IS DECIDED THE NAME DOES NOT APPEAR TO VIOLATE POLICY, OR THIS TEMPLATE HAS BEEN IN PLACE FOR A WHILE WITH NO ACTION\. --> {{#ifexpr: \(\{\{CURRENTTIMESTAMP\}\} - \d+\) < \d+ \| \[\[Category:User talk pages with conflict of interest notices\|{{PAGENAME}}]] \| }} {{#ifeq:{{BASEPAGENAME}}\|.*\|\[\[Category:Wikipedia usernames with possible policy issues\|{{PAGENAME}}]]}} <!-- \*\*\* -->/ig,'');
text = text.trim();
api.postWithToken( 'edit', {
action: 'edit',
title: mw.config.get('wgPageName'),
summary: 'Remove [[:Category:Wikipedia usernames with possible policy issues]] for inactive account',
text: text2
}).done( function ( data ) {
mw.notify("Removed the category.");
});
});
}
// end rm_uaa function