The official discord link if you wish to join the discord: https://discord.gg/j5RKwCvAFu

The background art comes from Cherylann1960.

Support the wiki on our official Ko-Fi page or Patreon page!

MediaWiki:Common.js: Difference between revisions

From The Codex
 
(78 intermediate revisions by 4 users not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
 
mw.loader.load("//en.wikipedia.org/wiki/User:CKSkies/rcwidget.js?action=raw&ctype=text/javascript");
 
 
window.AutoEditDropdownConfig = {
window.AutoEditDropdownConfig = {
     expandedAreaContribute: true,
     expandedAreaContribute: true,
     expandedAreaEdit: false
     expandedAreaEdit: false
};
};
 
window.ajaxRefresh = 60000;
window.ajaxRefresh = 60000;
window.ajaxPages = [
window.ajaxPages = [
    'Special:WikiActivity',
     'Special:RecentChanges',
     'Special:RecentChanges',
     'Special:Contributions',
     'Special:Contributions',
Line 19: Line 21:
     'Special:Statistics',
     'Special:Statistics',
     'Special:ListFiles',
     'Special:ListFiles',
    'Category:Speedy_deletion_candidates',
    'Category:Speedy_move_candidates'
];
];
window.AjaxRCRefreshText = 'Auto-refresh';
window.AjaxRCRefreshText = 'Auto-refresh';
window.AjaxRCRefreshHoverText = 'Automatically refresh the page';
window.AjaxRCRefreshHoverText = 'Automatically refresh the page';
 
window.LockForums = {
    expiryDays: Infinity,
    warningDays: 90,
    warningMessage: "This thread has not been commented on for over <warningDays> days. There is no need to reply, unless it is part of the versus forum."};
window.UserTagsJS = {
window.UserTagsJS = {
     modules: {},
     modules: {},
Line 146: Line 141:
UserTagsJS.modules.inactive = {
UserTagsJS.modules.inactive = {
     days: 30,
     days: 30,
    // namespaces: [0, 'Talk', 'User', 'User talk', 'Forum'], // Only articles, talk pages, user pages, user talk pages or forums edits count, other Wikia namespace edits don't count
     zeroIsInactive: true // 0 edits = inactive
     zeroIsInactive: true // 0 edits = inactive
};
};
Line 174: Line 168:
     'bannedfromchat'
     'bannedfromchat'
];
];
UserTagsJS.modules.custom = {
 
    'Kavpeny': ['former-bureaucrat'],
    'DarkLK': ['former-bureaucrat', 'guru', 'consultant'],
    'A6colute': ['js-helper', 'css-helper', 'template-helper'],
    'KamiYasha': ['former-sysop'],
    'Spinosaurus75DinosaurFan': ['calc'],
    'Executor N0': ['calc'],
    'AidenBrooks999': ['calc', 'former-threadmoderator'],
    'Thebluedash': ['former-calc', 'former-threadmoderator'],
    'Antoniofer': ['former-calc'],
    'Darkanine': ['former-calc', 'former-sysop', 'former-human-resources'],
    'The real cal howard': ['former-calc'],
    'ArbitraryNumbers': ['former-calc', 'former-threadmoderator'],
    'Golden Void': ['former-calc', 'former-threadmoderator'],
    'Liger686': ['former-calc', 'former-threadmoderator'],
    'Kepekley23': ['calc'],
    'TataHakai': ['calc'],
    'Zanybrainy2000': ['former-calc'],
    'RavenSupreme': ['former-calc'],
    'Therefir': ['calc'],
    'Mr. Bambu': ['calc'],
    'Peter "Quicksilver" Maximoff': ['image-helper'],
    'The Foolish Omniscient Guy': ['image-helper'],
    'Galaxian Pyron': ['founder', 'former-bureaucrat'],
    'Polar-kun': ['former-bureaucrat'],
    'SeiryuShin': ['former-sysop'],
    'Rocks75': ['former-sysop'],
    'DontTalkDT': ['former-calc', 'consultant'],
    'Darkness552': ['former-sysop'],
    'Sheoth': ['former-sysop'],
    'SchutzenDunkelZiel1217': ['former-sysop'],
    'Gwynbleiddd': ['former-sysop', 'former-calc'],
    'LordAizenSama': ['former-sysop'],
    'KuuIchigo': ['former-sysop', 'former-calc'],
    'TheMightyRegulator': ['former-sysop'],
    'Alakabamm': ['former-sysop', 'former-calc'],
    'ThePerpetual': ['former-sysop', 'former-calc'],
    'CrossverseCrisis': ['former-sysop'],
    'Professor Voodoo': ['former-sysop'],
    'Dekoshu': ['former-content-moderator'],
    'The Living Tribunal1': ['former-content-moderator', 'former-calc'],
    'Basilisk1995': ['former-content-moderator'],
    'Colonel Krukov': ['former-content-moderator', 'former-chatmoderator'],
    'Illuminati478': ['former-threadmoderator', 'former-calc'],
    'Unclechairman': ['former-threadmoderator'],
    'SwordSlayer99': ['former-threadmoderator'],
    'Faisal Shourov': ['former-threadmoderator'],
    'Austrian-Man-Meat': ['former-threadmoderator', 'former-calc'],
    'LordXcano': ['former-threadmoderator', 'former-calc'],
    'RadicalMrR': ['former-threadmoderator', 'former-calc'],
    'VenomElite': ['former-threadmoderator'],
    'Talonmask': ['former-chatmoderator'],
    'AkuAkuAkuma': ['former-chatmoderator'],
    'Byakuya "Senbonzakura" Kuchiki': ['former-chatmoderator'],
    'Rib78': ['former-calc'],
    'Gallavant': ['former-calc'],
    'DMUA': ['calc'],
    'Crimson Azoth': ['calc'],
    'Ugarik': ['calc'],
    'AlexSoloVaAlFuturo': ['calc'],
    'Damage3245': ['calc'],
    'ClassicGameGuys': ['former-calc'],
    'Lina Shields': ['former-calc', 'former-sysop'],
    'Aparajita': ['former-calc'],
    'Grudgeman1706': ['former-threadmoderator'],
    'FanofRPGs': ['former-calc'],
    'Numbersguy': ['former-calc'],
    'ShieldsPlus': ['former-calc', 'former-sysop'],
    'Assaltwaffle': ['former-calc', 'former-sysop'],
    'ScarletFirefly': ['former-threadmoderator'],
    'Promestein': ['human-resources'],
    'Reppuzan': ['former-sysop', 'former-human-resources'],
    'Celestial Pegasus': ['human-resources'],
    'Kaltias': ['former-sysop', 'former-human-resources'],
    'SomebodyData': ['human-resources'],
    'Legion350': ['former-content-moderator'],
    'ALRF': ['former-chatmoderator', 'former-content-moderator'],
    'The Everlasting': ['former-sysop'],
    'Fllflourine': ['former-content-moderator', 'former-chatmoderator'],
    'Burning Full Fingers': ['former-content-moderator'],
    'Aeyu': ['former-threadmoderator'],
    'Super Saiyan God Julian': ['former-threadmoderator'],
    'PaChi2': ['former-threadmoderator'],
    'Sandman31': ['former-threadmoderator'],
    'LordGriffin1000': ['former-threadmoderator'],
    'JustSomeWeirdo': ['former-threadmoderator'],
    'Hop Hoppington-Hoppenhiemer': ['former-threadmoderator'],
    'Sayo_Yasuda': ['former-chatmoderator'],
    'Skalt711': ['image-helper'],
    'The Divine Phoenix': ['image-helper'],
    'Colonel Krukov': ['image-helper'],
    'Andytrenom': ['sysop', 'human-resources'],
    'Dargoo Faust': ['sysop', 'human-resources'],
    'Wokistan': ['sysop', 'human-resources'],
    'Matthew Schroeder': ['former-sysop'],
    'First Witch': ['former-chatmoderator'],
    'Azathoth the Abyssal Idiot': ['former-bureaucrat'],
    'WeeklyBattles': ['former-sysop'],
    'MrKingOfNegativity': ['former-sysop']
};
UserTagsJS.modules.metafilter = {
UserTagsJS.modules.metafilter = {
    // Remove inactive from all bureaucrats, sysops, bots, global bots, staff, wikia utility and vstf
'inactive': [
    'inactive': [
         'sysop',
         'sysop',
         'bureaucrat',
         'bureaucrat',
Line 293: Line 187:
// UserTagsJS.modules.stopblocked = true; //Enabled by default
// UserTagsJS.modules.stopblocked = true; //Enabled by default
//Manually turn off by changing true -> false
//Manually turn off by changing true -> false
 
// Username script //  
// Username script //  
(function () {  
(function () {  
if (wgUserName !== null) $('span.insertusername').text(wgUserName);
 
mw.config.get('wgUserName');
 
if (mw.config.get('wgUserName') !== null) $('span.insertusername').text(mw.config.get('wgUserName'));
})();
})();
 
// Bureaucrat promotion warning message //
// Bureaucrat promotion warning message //
!function() {
!function() {
     if (wgCanonicalSpecialPageName !== 'Userrights') return;
     if (mw.config.get('wgCanonicalSpecialPageName') !== 'Userrights') return;
     $('#mw-content-text').on('change', '#wpGroup-bureaucrat', function() {
     $('#mw-content-text').on('change', '#wpGroup-bureaucrat', function() {
     if ($('#wpGroup-bureaucrat').attr('checked') && !confirm('Do you truly want to appoint a bureaucrat?')) $('#wpGroup-bureaucrat').attr('checked', null);
     if ($('#wpGroup-bureaucrat').attr('checked') && !confirm('Do you truly want to appoint a bureaucrat?')) $('#wpGroup-bureaucrat').attr('checked', null);
     });
     });
}();
}();
window.pPreview = $.extend(true, window.pPreview, {RegExp: (window.pPreview || {}).RegExp || {} });
window.pPreview.noimage = 'https://thecodex.wiki/images/e/e6/Site-logo.png';
window.pPreview.tlen = 1000;
//==============================================================
// Sorts content on Special:WhatLinksHere alphabetically
//==============================================================
(function($) {
    if (mw.config.get('wgCanonicalSpecialPageName') !== 'Whatlinkshere') return;
    var sorted_list,
        $list = $('#mw-whatlinkshere-list');
    sorted_list = $list.children('li').sort(function (a, b) {
        return ($(a).find('a:first').attr('title') >
        $(b).find('a:first').attr('title')) ? 1 : -1;});
    $list.children('li').remove();
    $list.append(sorted_list);
})(jQuery);
//==============================================================
// Personalized imports
//==============================================================
// Import scripts if user has one of the following ranks:
/* Rollback, Content Moderator, Admin, Bureaucrat, Content Volunteer, */
(function(){
const wgUserGroups = mw.config.get('wgUserGroups');
if(wgUserGroups.includes('rollback') ||
  wgUserGroups.includes('content-moderator') ||
  wgUserGroups.includes('sysop') ||
  wgUserGroups.includes('bureaucrat') ||
  wgUserGroups.includes('content-volunteer') ||
  wgUserGroups.includes('vstf') ||
  wgUserGroups.includes('helper') ||
  wgUserGroups.includes('staff')){
      importArticles({
            type: 'script',
            articles: [
            'u:dev:MediaWiki:AjaxRename/code.js'
        ]
    });
}
if(wgUserGroups.includes('sysop') ||
  wgUserGroups.includes('bureaucrat') ||
  wgUserGroups.includes('content-volunteer') ||
  wgUserGroups.includes('vstf') ||
  wgUserGroups.includes('helper') ||
  wgUserGroups.includes('staff')){
      importArticles({
            type: 'script',
            articles: [
            'u:dev:MediaWiki:WHAM/code.2.js',
            'u:dev:MediaWiki:AjaxUserRights.js'
        ]
    });
}
}());
//==============================================================
// Category Sorter Resolution
//==============================================================
!function(cfg) {
    // sorts categories by name
    // do not bother anons
    if (cfg.loaded || !mw.config.get('wgUserName')) return;
    cfg.loaded = !0;
   
    var targets = [
            '#mw-normal-catlinks:first > ul:first > li',
            '#mw-hidden-catlinks:first > ul:first > li',
            '#articleCategories .category',
        ];
   
    function sorter(a, b) {
        // locale will be determined automatically. probably. works on my machine
        return (a.textContent || '').localeCompare(b.textContent || '');
    }// sorter
    $(function() {
        targets.forEach(function(target) {
            var $target = $(target),
                $parent = $target.parent(),// cache parent, cuz it will be lost after .remove
                sorted = $target.sort(sorter);
            $target.remove();
            $parent.append(sorted);
        });
    });
}((window.fng = window.fng || {}).catsorter = window.fng.catsorter || {});
window.AddRailModule = ['Template:RailModule', 'Template:NewPagesModule'];
// Template:Tabs
$(function() {
// If a sub-tab is "selected", make the parent tabs also "selected"
$('.at-selected').parents('.article-tabs li').each(function () {
$(this).addClass('at-selected');
});
// Margin fix
$('.article-tabs .at-selected .article-tabs').each(function () {
// Get height of subtabs
var $TabsHeight = $(this).height();
// Increase bottom margin of main tabs
$(this).parents('.article-tabs').last().css('margin-bottom' , '+=' + $TabsHeight);
});
});
// END of Template:Tabs
// Script for floating actions scroll
// Custom Scripts

Latest revision as of 03:57, 28 October 2024

/* Any JavaScript here will be loaded for all users on every page load. */

mw.loader.load("//en.wikipedia.org/wiki/User:CKSkies/rcwidget.js?action=raw&ctype=text/javascript");


window.AutoEditDropdownConfig = {
    expandedAreaContribute: true,
    expandedAreaEdit: false
};

window.ajaxRefresh = 60000;
window.ajaxPages = [
    'Special:RecentChanges',
    'Special:Contributions',
    'Special:Log',
    'Special:Log/move',
    'Special:AbuseLog',
    'Special:NewFiles',
    'Special:NewPages',
    'Special:Watchlist',
    'Special:Statistics',
    'Special:ListFiles',
];
window.AjaxRCRefreshText = 'Auto-refresh';
window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

window.UserTagsJS = {
    modules: {},
    tags: {
        // group: { associated tag data },
        founder: {
            u: 'Founder',
            order: 1
        },
        bureaucrat: {
            u: 'Bureaucrat',
            order: 2
        },
        'former-bureaucrat': {
            u: 'Retired Bureaucrat',
            order: 3
        },
        sysop: {
            u: 'Administrator',
            order: 4
        },
        'former-sysop': {
            u: 'Retired Administrator',
            order: 5
        },
        'bot-global': {
            u: 'Global Bot',
            order: 7
        },
        bot: {
            u: 'Bot',
            order: 8
        },
        'content-moderator': {
            u: 'Content Moderator',
            order: 10
        },
        'former-content-moderator': {
            u: 'Retired Content Moderator',
            order: 11
        },
        threadmoderator: {
            u: 'Discussion Moderator',
            order: 13
        },
        'former-threadmoderator': {
            u: 'Retired Discussion Moderator',
            order: 14
        },
        chatmoderator: {
            u: 'Chat Moderator',
            order: 16
        },
        'former-chatmoderator': {
            u: 'Retired Chat Moderator',
            order: 17
        },
        rollback: {
            u: 'Rollback',
            order: 19
        },
        'former-rollback': {
            u: 'Former Rollback',
            order: 20
        },
        calc: {
            u: 'Calc Group',
            order: 22
        },
        'former-calc': {
            u: 'Retired Calc Group',
            order: 23
        },
        guru: {
            u: 'Guru',
            order: 40
        },
        'js-helper': {
            u: 'JS Helper',
            order: 51
        },
        'css-helper': {
            u: 'CSS Helper',
            order: 52
        },
        'image-helper': {
            u: 'Image Helper',
            order: 53
        },
        'template-helper': {
            u: 'Templates Helper',
            order: 54
        },
        'human-resources': {
            u: 'Human Resources',
            order: 55
        },
        'former-human-resources': {
            u: 'Retired Human Resources',
            order: 56
        },        
        consultant: {
            u: 'Consultant',
            order: 100
        },
        bannedfromchat: {
            u: 'Banned from Chat',
            order: 500
        },
        inactive: {
            u: 'Inactive',
            order: 1 / 0
        }
    }
};
UserTagsJS.modules.inactive = {
    days: 30,
    zeroIsInactive: true // 0 edits = inactive
};
UserTagsJS.modules.nonuser = (mediaWiki.config.get('skin') === 'monobook');
UserTagsJS.modules.autoconfirmed = true; // Switch on Autoconfirmed User check
UserTagsJS.modules.newuser = {
    computation: function(days, edits) {
        // If the expression is true then they will be marked as a new user
        // If the expression is false then they won't.
        // In this instance, newuser is removed as soon as the user gets 30
        // edits, OR as soon as they have been present for 10 days, whichever
        // happens first.
        return days < 10 && edits < 30;
    }
};
// NOTE: bannedfromchat displays in Oasis but is not a user-identity group so must be checked manually
UserTagsJS.modules.mwGroups = [
    'bureaucrat',
    'sysop',
    'bot',
    'bot-global',
    'content-moderator',
    'threadmoderator', 
    'chatmoderator',
    'patroller',
    'rollback',
    'bannedfromchat'
];

UserTagsJS.modules.metafilter = {
	'inactive': [
        'sysop',
        'bureaucrat',
        'bot',
        'bot-global',
        'staff',
        'util',
        'vstf'
    ], 
    'sysop': ['bot', 'bot-global'], // Remove "Administrator" tag from bots and global bots
    'content-moderator': ['bureaucrat', 'sysop'], // Remove "Content Moderator" tag from bureaucrats and administrators
    'threadmoderator': ['bureaucrat', 'sysop'], // Remove "Discussions Moderator" tag from bureaucrats and administrators
    'chatmoderator': ['bureaucrat', 'sysop'], // Remove "Chat Moderator" tag from bureaucrats and administrators
    'rollback': ['bureaucrat', 'sysop'] // Remove "Rollback" tag from bureaucrats and administrators
};
// UserTagsJS.modules.stopblocked = true; //Enabled by default
//Manually turn off by changing true -> false

// Username script // 

(function () { 

mw.config.get('wgUserName');

if (mw.config.get('wgUserName') !== null) $('span.insertusername').text(mw.config.get('wgUserName'));
	 
})();

// Bureaucrat promotion warning message //
!function() {
    if (mw.config.get('wgCanonicalSpecialPageName') !== 'Userrights') return;
    $('#mw-content-text').on('change', '#wpGroup-bureaucrat', function() {
    if ($('#wpGroup-bureaucrat').attr('checked') && !confirm('Do you truly want to appoint a bureaucrat?')) $('#wpGroup-bureaucrat').attr('checked', null);
    });
}();

window.pPreview = $.extend(true, window.pPreview, {RegExp: (window.pPreview || {}).RegExp || {} });
window.pPreview.noimage = 'https://thecodex.wiki/images/e/e6/Site-logo.png';
window.pPreview.tlen = 1000;

//==============================================================
// Sorts content on Special:WhatLinksHere alphabetically
//==============================================================
 
(function($) {
    if (mw.config.get('wgCanonicalSpecialPageName') !== 'Whatlinkshere') return;
    var sorted_list,
        $list = $('#mw-whatlinkshere-list');
    sorted_list = $list.children('li').sort(function (a, b) {
        return ($(a).find('a:first').attr('title') > 
        $(b).find('a:first').attr('title')) ? 1 : -1;});
    $list.children('li').remove();
    $list.append(sorted_list);
})(jQuery);

//==============================================================
// Personalized imports
//==============================================================
// Import scripts if user has one of the following ranks:
/* Rollback, Content Moderator, Admin, Bureaucrat, Content Volunteer, */

(function(){
const wgUserGroups = mw.config.get('wgUserGroups');

if(wgUserGroups.includes('rollback') || 
   wgUserGroups.includes('content-moderator') ||
   wgUserGroups.includes('sysop') ||
   wgUserGroups.includes('bureaucrat') ||
   wgUserGroups.includes('content-volunteer') ||
   wgUserGroups.includes('vstf') ||
   wgUserGroups.includes('helper') ||
   wgUserGroups.includes('staff')){
      importArticles({
            type: 'script',
            articles: [
            'u:dev:MediaWiki:AjaxRename/code.js'
        ]
    });
}

if(wgUserGroups.includes('sysop') ||
   wgUserGroups.includes('bureaucrat') ||
   wgUserGroups.includes('content-volunteer') ||
   wgUserGroups.includes('vstf') ||
   wgUserGroups.includes('helper') ||
   wgUserGroups.includes('staff')){
      importArticles({
            type: 'script',
            articles: [
            'u:dev:MediaWiki:WHAM/code.2.js',
            'u:dev:MediaWiki:AjaxUserRights.js'
        ]
    });
}
}());
//==============================================================
// Category Sorter Resolution
//==============================================================
!function(cfg) {
    // sorts categories by name
    // do not bother anons
    if (cfg.loaded || !mw.config.get('wgUserName')) return;
    cfg.loaded = !0;
    
    var targets = [
            '#mw-normal-catlinks:first > ul:first > li',
            '#mw-hidden-catlinks:first > ul:first > li',
            '#articleCategories .category',
        ];
    
    function sorter(a, b) {
        // locale will be determined automatically. probably. works on my machine
        return (a.textContent || '').localeCompare(b.textContent || '');
    }// sorter

    $(function() {
        targets.forEach(function(target) {
            var $target = $(target),
                $parent = $target.parent(),// cache parent, cuz it will be lost after .remove
                sorted = $target.sort(sorter);
            $target.remove();
            $parent.append(sorted);
        });
    });
}((window.fng = window.fng || {}).catsorter = window.fng.catsorter || {});

window.AddRailModule = ['Template:RailModule', 'Template:NewPagesModule'];

// Template:Tabs
$(function() {
	// If a sub-tab is "selected", make the parent tabs also "selected"
	$('.at-selected').parents('.article-tabs li').each(function () {
		$(this).addClass('at-selected');
	});

	// Margin fix
	$('.article-tabs .at-selected .article-tabs').each(function () {
		// Get height of subtabs
		var $TabsHeight = $(this).height();

		// Increase bottom margin of main tabs
		$(this).parents('.article-tabs').last().css('margin-bottom' , '+=' + $TabsHeight);
	});
});
// END of Template:Tabs

// Script for floating actions scroll

// Custom Scripts