User:Hoo man/localRemoveSysops.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*
* [[m:user:Hoo man]]; Version 2.0.0; 2012-07-22;
* This tool can tell whether there are local 'crats who can remove the sysop flag or not
* The link to look that up is in the toolbox (p-tb)
* Tested in IE and FF with vector and monobook
*
* DO NOT COPY AND PASTE, instead use:
// A tool that can tell whether local 'crats can remove the sysop flag or not, by [[m:user:Hoo man]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/localRemoveSysops.js&action=raw&ctype=text/javascript');
*/
(function($, mw) {
mw.messages.set({
'hoo-localRemoveSysops-toolbarText' : 'Can local \'crats remove sysop?',
'hoo-localRemoveSysops-title' : 'Can local bureaucrats remove the sysop flag?',
'hoo-localRemoveSysops-error' : 'An error occurred, please try again.',
'hoo-localRemoveSysops-can' : 'There are local bureaucrats and they can remove the sysop flag.',
'hoo-localRemoveSysops-cant' : 'There aren\'t any local bureaucrats and/or they can\'t remove the sysop flag.'
});
mw.loader.using('mediawiki.util', function() {
mw.util.addPortletLink('p-tb', '#', mw.messages.get('hoo-localRemoveSysops-toolbarText'), 'localRemoveSysopsPortlet');
$('#localRemoveSysopsPortlet').click( function() {
$.getJSON(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&meta=siteinfo&siprop=usergroups&sinumberingroup=1&format=json&callback=?', function(data) {
// success ;-)
var tmp = data.query.usergroups;
for(var i = 0; i<tmp.length; i++) {
if(tmp[i].name === 'bureaucrat') {
if($.inArray( 'sysop', tmp[i].remove ) !== -1 && tmp[i].number !== '0') {
alert(mw.messages.get( 'hoo-localRemoveSysops-title' ) + '\n\n' + mw.messages.get( 'hoo-localRemoveSysops-can' ) );
}else{
alert(mw.messages.get( 'hoo-localRemoveSysops-title' ) + '\n\n' + mw.messages.get( 'hoo-localRemoveSysops-cant' ) );
}
return;
}
}
})
//an error occured
.fail( function() { alert( mw.messages.get( 'hoo-localRemoveSysops-error' ) ); } );
} );
});
}(jQuery, mediaWiki));