User:Caburum/global.js

// Hello and welcome to my global JS page window.dev = window.dev || {}; window.caburum = { shouldRunGlobal: window.location.search.indexOf('useglobaljs') === -1 && window.location.search.indexOf('usecabjs') === -1, // return true if the global script should run, shouldRunLocal: window.location.search.indexOf('uselocaljs') === -1 && window.location.search.indexOf('usecabjs') === -1, // return true if the local script should run ran: false, init: function { if (!this.shouldRunGlobal) { this.log('Did not execute global.js from Community Central, disabled'); } else if (!window.caburum.ran) { this.log('Executed global.js from Community Central'); this.exec; this.ran = true; }		mw.config.get('wgUserGroups').forEach(function(group) { // Sets the current user's groups to true in groups object			window.caburum.groups[group] = true;		}); },	exec: function { $.extend(window, { // Script config			AjaxRename: { // w:c:dev:AjaxRename				check: {					leaveredirect: false,					watch: false,					movetalk: true				},				renameReasons: {					'Normal': {						'Misnamed': 'Misnamed',						'Better name': 'Better name',						'Fixing capitalization': 'Fixing capitalization'					},					'Other': {						'Page does not belong in namespace': 'Page does not belong in namespace',					}				}			},			andrewds1021: {				view_notifications_users: { // w:c:dev:ViewNotificationsUsers					all_types: true,					content: 'name'				},				ignore_notifications: { // w:c:dev:IgnoreNotifications					ignore_errors: true,					filters: [						{							types: 'discussion-upvote'						},						{							wiki_ids: [								2078067,								2411433,								2417668,								2386902							],							types: 'announcement-target'						}					]				}			},			AutoCreateUserPagesConfig: { // w:c:dev:MediaWiki:AutoCreateUserPages.js content: { 2: '',					3: false, 1202: false },				summary:'Automated user page creation' },			dev: { i18n: {overrides: { // i18n overrides Rollback: { summary: 'Reverted edits by $1 (talk) to last version by $2' }				}}			},			FCButtons: [ // w:c:dev:FastCreate /*{					label: 'Create userpage', target: 'User:Caburum', summary: 'Creating userpage', content: '', alwaysDisplay: true, placement: '.wds-global-navigation__user-menu .wds-list' },*/				{					label: 'Create bot userpage', target: 'User:CaburumBot', summary: 'Creating my bot\'s userpage', content: '', alwaysDisplay: true, placement: '.wds-global-navigation__user-menu .wds-list' }			],			fdButtons: [ // w:c:dev:FastDelete {					summary: 'Housekeeping', label: 'HK' },				{					summary: 'Vandalism', label: 'V'				}, {					summary: 'Spam', label: 'S'				}, {					summary: 'Duplicate', label: 'Dp' }			],			globalNavButtons: [ // w:c:dev:GlobalNavButtons /* Patrolling */ window.caburum.globalNavPage('RC', 'Special:RecentChanges', {m: 'RC'}), window.caburum.globalNavPage('New files', 'Special:NewFiles', {p: 'RC'}), window.caburum.globalNavPage('New pages', 'Special:NewPages', {p: 'RC'}), window.caburum.globalNavPage('New messages', 'Special:SocialActivity', {p: 'RC', r: 'containerTypes=WALL'}), window.caburum.globalNavPage('New comments', 'Special:SocialActivity', {p: 'RC', r: 'containerTypes=ARTICLE_COMMENT'}), /* Social */ window.caburum.globalNavLink('Forum', mw.config.get('wgScriptPath') + '/f', {m: false, p: false}), /* MediaWiki */ window.caburum.globalNavPage('MediaWiki', 'Special:AllPages/MediaWiki:', {m: 'MW'}), window.caburum.globalNavPage('Common CSS', 'MediaWiki:Common.css', {p: 'MW'}), window.caburum.globalNavPage('Wikia CSS', 'MediaWiki:Wikia.css', {p: 'MW'}), window.caburum.globalNavPage('Common JavaScript', 'MediaWiki:Common.js', {p: 'MW'}), window.caburum.globalNavPage('Wikia JavaScript', 'MediaWiki:Wikia.js', {p: 'MW'}), window.caburum.globalNavPage('ImportJS', 'MediaWiki:ImportJS', {p: 'MW'}), window.caburum.globalNavPage('Wiki navigation', 'MediaWiki:Wiki-navigation', {p: 'MW'}), /* Personal */ window.caburum.globalNavLink('ME', 'https://community.fandom.com/wiki/Special:MyPage', {m: 'ME'}), window.caburum.globalNavPage('Local JavaScript', 'Special:MyPage/common.js', {p: 'ME'}), window.caburum.globalNavPage('Local CSS', 'Special:MyPage/common.css', {p: 'ME'}), window.caburum.globalNavLink('Global JavaScript', 'https://community.fandom.com/wiki/Special:MyPage/global.js', {p: 'ME'}), window.caburum.globalNavLink('Global CSS', 'https://community.fandom.com/wiki/Special:MyPage/global.css', {p: 'ME'}), /* Wikis */ window.caburum.globalNavLink('WIKIS', 'https://caburum.fandom.com/wiki/User:Caburum/RecentChanges', {m: 'W'}), window.caburum.globalNavLink('Among Us Wiki', 'https://among-us.fandom.com/wiki/', {p: 'W'}), window.caburum.globalNavLink('Community Central', 'https://community.fandom.com/wiki/', {p: 'W'}), window.caburum.globalNavLink('Dev Wiki', 'https://dev.fandom.com/wiki/', {p: 'W'}), window.caburum.globalNavLink('Discord Wiki', 'https://discord.fandom.com/wiki/', {p: 'W'}), window.caburum.globalNavLink('Test Wiki', 'https://caburum.fandom.com/wiki/', {p: 'W'}), window.caburum.globalNavLink('Customize Your Wiki', 'https://custom.fandom.com/wiki/', {p: 'W'}) ],			MessageBlock: { // w:c:dev:MessageBlock title : 'Blocked', message : 'You have received a $2 block for the reason: \'$1\'. Unless otherwise stated, you may appeal your block on my message wall at Community Central.', autocheck : true }		});

if (window.caburum.groups['sysop'] || window.caburum.groups['content-moderator'] || window.caburum.groups['threadmoderator']) { window.globalNavButtons.push(				window.caburum.globalNavPage('Message deletion', 'Special:SocialActivity', {p: 'RC', r: 'deleted=true&containerTypes=WALL'}),				window.caburum.globalNavLink('Reported posts', mw.config.get('wgScriptPath') + '/f/reported', {p: 'RC'})			); }

if (mw.config.get('wgNamespaceIds').gadget) { window.globalNavButtons.push(				window.caburum.globalNavPage('Gadgets', 'Special:Gadgets', {p: 'MW'})			); }		// Execute common.js		if (!window.caburum.shouldRunLocal) { window.caburum.log('Did not execute common.js, disabled'); } else { mw.hook('caburum.runLocalJS').fire; }

// Load scripts based on user groups var articles = []; window.caburum.scripts.forEach(function(source) {			$.each(source.scripts, function(script, groups) { if (groups.filter(function(group) { return !window.caburum.groups[group]; // True if user has group }).length > 0) { articles.push(source.prefix + script + '.js'); }			});		});		importArticles({			type: 'script',			articles: articles		}); },	scripts: [ // Scripts to import per source, dependent on user groups { // Dev Wiki prefix: 'u:dev:MediaWiki:', scripts: { // Maintenance 'AjaxBatchDelete': ['sysop', 'content-moderator'], 'AjaxRename/ucp': ['*'], 'FastDelete/code': ['sysop', 'content-moderator'], 'Rollback/code': ['*'], 'AnchoredRollback/code': ['*'], 'ListFiles/code': ['*'], 'MassNullEdit/code': ['*'],

// Admin //'AjaxBlock/code': ['sysop'], // Conflicts with MessageBlock 'MessageBlock/code': ['sysop'], 'SOAPReport': ['*'], 'WHAM/code.2': ['sysop', 'content-moderator', 'threadmoderator', 'rollback'],

// Tools 'QuickDiff/code': ['*'], // 'MultiUpload', 'UploadMultipleFiles': ['*'], 'LastEdited/code': ['*'], 'FastCreate': ['*'], 'QuickPurge': ['*'], 'CopyTitle': ['*'],

// Personal 'DisplayTimer/code': ['*'], 'AutoCreateUserPages': ['*'], 'GlobalNavButtons': ['*'],

// Social 'ViewNotificationsUsers': ['*'], 'IgnoreNotifications': ['*'], 'UserAndIPTools': ['*'], 'UserAccountAge/code2': ['*'],

// Editing // 'DecodeURI/code': ['*'], 'ImageMapEdit': ['*'], }		},		{ // Caburum Testing Wiki prefix: 'u:caburum:MediaWiki:', scripts: {} },		{ // Personal prefix: 'u:caburum:User:Caburum/', scripts: { 'MassEdit': ['*'] }		}	],	groups: {}, // Stored user group object, value is true if user has group, populated in init log: function { // Formatted console.log console.log.apply(null, Array.prototype.concat('%c[CABURUM]', 'color: #00D6D6; background-color: #202124;', Array.prototype.slice.call(arguments))); },	globalNavPage: function(title, page, args) { // Creates a GlobalNavButtons object for an internal page args = { p: args.p || undefined, r: args.r || undefined, m: args.m || false };		return { text: title, url: mw.util.getUrl(page) + (args.r ? '?' + args.r : ''), isMain: args.m ? true : false, whoIsMain: args.m ? false : args.p, shortName: args.m ? args.m : title };	},	globalNavLink: function(title, url, args) { // Creates a GlobalNavButtons object for an external link args = { p: args.p || undefined, m: args.m || false };		return { text: title, url: url, isMain: args.m ? true : false, whoIsMain: args.m ? false : args.p, shortName: args.m ? args.m : title };	}, };

$(window.caburum.init.bind(window.caburum));