User:Gary/user groups.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. |
![]() | Documentation for this user script can be added at User:Gary/user groups. |
/*
USER GROUPS SCRIPT
NORMAL GROUPS (18 total, as of February 2, 2011):
(all)
accountcreator
sysop (administrator)
autoreviewer (auto patrolled)
bot
bureaucrat
checkuser
confirmed
abusefilter (edit filter manager)
founder
ipblock-exempt
import
oversight
researcher
reviewer
rollbacker
steward
transwiki
SPECIAL GROUPS (3)
(anonymous)
autoconfirmed
user
EXAMPLE USAGE (all nouns are in singular form):
<div class="for-sysop-only"></div>
AND
<div class="not-for-sysop"></div>
NOTES
- (all) has no associated class.
- The associated class for (anonymous) uses "anonymous".
*/
// do (anonymous) first; they have NO groups
if (!wgUserGroups)
{
appendCSS('.not-for-anonymous { display: none; }');
}
else
{
// normal user groups; (all) group is missing
var allUserGroups = { 'accountcreator': true, 'sysop': true, 'autoreviewer': true, 'bot': true, 'bureaucrat': true, 'checkuser': true, 'confirmed': true, 'abusefilter': true, 'founder': true, 'ipblock-exempt': true, 'import': true, 'oversight': true, 'researcher': true, 'reviewer': true, 'rollbacker': true, 'steward': true, 'transwiki': true, };
for (var group in allUserGroups) createGroupCss(group);
// special user groups; (anonymous) is missing, will do last
var specialUserGroups = { 'autoconfirmed': true, 'user': true, };
for (var group in specialUserGroups) createGroupCss(group);
// (anonymous) users
appendCSS('.for-anonymous-only { display: none; }');
}
function createGroupCss(group)
{
if (userHasGroup(group)) appendCSS('.not-for-' + group + ' { display: none; }'); // 'not-for-X'
else appendCSS('.for-' + group + '-only { display: none; }'); // 'for-X-only'
}
function userHasGroup(group)
{
for (var i = 0; i < wgUserGroups.length; i++)
{
if (group == wgUserGroups[i])
return true;
}
return false;
}