Jump to content

User:Gary/user groups.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Gary (talk | contribs) at 20:02, 2 February 2011 (moved User:Gary King/tests.js to User:Gary King/user groups.js). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/*
	USER GROUPS (18 in total, as of February 2, 2011):
	(anonymous), accountcreator, sysop (administrator), autoreviewer (auto patrolled), bot, bureaucrat, checkuser, confirmed, abusefilter (edit filter manager), founder, ipblock-exempt, import, oversight, researcher, reviewer, rollbacker, steward, transwiki
	
	EXAMPLE USAGE:
	
	<div class="for-sysop-only"></div>
	<div class="not-for-sysop"></div>
*/

var allUserGroups = { ' ': true, '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)
{
	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;
}