User:Dragoniez/Gadget-MarkBLocked

A sample image of blocked/locked users' links getting marked up

Gadget-MarkBLocked is a script forked from m:User:Dragoniez/Mark (B)Locked Global, initially inspired by en:MediaWiki:Gadget-markblocked.js. This script can be easily incorporated into your local wiki as a gadget, and all you have to do is configure the 'MarkBLocked' JavaScript object for proper localization.

This script:

  • Marks up locally blocked users and single IPs
  • (*) Can mark up single IPs included in locally-blocked IP ranges
  • (*) Can mark up globally locked users
  • (*) Can mark up globally blocked single IPs and IP ranges

The original markblocked only supports the non-starred feature, primarily because the starred ones could end up in performance issues depending on the browser and computer environments of the editors who use the script. Gadget-MarkBLocked overcomes this issue by preparing preferences settings; the starred features can be enabled/disabled anytime on the preferences page added by the script:

These are all the same, differing only in their page titles.

For interface administrators

edit

JavaScript

edit

The source code can be found here.

Gadgets-definition should have a line like the following:

MarkBLocked[ResourceLoader|targets=desktop,mobile|dependencies=mediawiki.util,mediawiki.api,mediawiki.user]|MarkBLocked.js|MarkBLocked.css

(Note: CSS must be loaded independently.)

For localization, configure the following JavaScript object:

var MarkBLocked = {
    // Portletlink configurations
    portletlink: {
        position: 'p-tb',
        text: 'MarkBLocked Preferences',
        id: 't-gmblp',
        tooltip: 'Configure MarkBLocked',
        accesskey: null,
        nextnode: null
    },
    /* -------------------------------------------------------------------------------------------------------------------------
        Register all local page names for [[Special:Contributions]] and [[Special:CentralAuth]] (without the namespace prefix).
        'contribs', 'contributions', 'ca', and 'centralauth' are registered by default: No need to register them.
        Note that the items are case-insensitive, compatible both with " " and "_" for spaces, and should NEVER be URI-encoded.
        If nothing needs to be registered, leave the array empty.
    ---------------------------------------------------------------------------------------------------------------------------- */
    contribs_CA: ['投稿記録', 'アカウント統一管理'], // Example setting for jawiki
    // Texts to show on [[Special:MarkBLockedPreferences]]
    configpage: {
        heading: 'MarkBLocked Preferences',
        check: {
            localips: 'Check whether single IPs are included in locally-blocked IP ranges',
            globalusers: 'Check whether registered users are globally locked',
            globalips: 'Check whether IPs are globally blocked'
            
        },
        save: {
            button: 'Save',
            doing: 'Saving preferences',
            done: 'Saved preferences',
            failed: 'Failed to save preferences',
            lastsave: 'Last saved at' // This is FOLLOWED by a space and a timestamp
        }
    },
    // Names of the local user groups that have the 'apihighlimits' user right
    apihighlimits: ['bot', 'sysop']
};

The source code can be found here.

This script adds the following classes to user links:

Selector Description Style
.gmbl-userlink Added to every user link
.gmbl-blocked-temp Temporarily blocked locally 07ST
.gmbl-blocked-indef Indefinitely blocked locally 04ST
.gmbl-blocked-partial Partially blocked locally DU
.gmbl-globally-locked Locked globally 04RU
.gmbl-globally-blocked-indef Temporarily blocked globally 04RU
.gmbl-globally-blocked-temp Indefinitely blocked globally 07RU
  • Abbreviations
    • 04: opacity 0.4
    • 07: opacity 0.7
    • ST: strike through
    • DU: dot under
    • RU: red under

Styles are determined based on which of the last 6 classes a given user link has. There're 26 = 64 combinations, and a list of them can be found on DropBox. Note that the source CSS is intentionally coded verbosely for the purpose of facilitating maintenance.