User:Maxim/rmuaa.js

// 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* {{#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* {{#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