Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

MediaWiki:Common.js: Difference between revisions

MediaWiki interface page
Blanked the page
Tags: Blanking Manual revert
No edit summary
Tag: Reverted
Line 1: Line 1:
mw.loader.using(['mediawiki.util']).then(function () {


    function injectThemeOption(container) {
        if (document.getElementById('lt-theme-test')) return;
        const wrapper = document.createElement('div');
        wrapper.id = 'lt-theme-test';
        wrapper.className = 'mw-portlet citizen-menu';
        const heading = document.createElement('div');
        heading.className = 'citizen-menu__heading';
        heading.textContent = 'Theme';
        const content = document.createElement('div');
        content.className = 'citizen-menu__content';
        const list = document.createElement('ul');
        list.className = 'citizen-menu__content-list';
        const item = document.createElement('li');
        item.className = 'mw-list-item mw-list-item-js';
        const radioWrapper = document.createElement('div');
        radioWrapper.className = 'citizen-client-prefs-radio';
        const input = document.createElement('input');
        input.type = 'radio';
        input.name = 'lt-theme-group';
        input.id = 'lt-theme-default';
        input.className = 'citizen-client-prefs-radio__input';
        const icon = document.createElement('span');
        icon.className = 'citizen-client-prefs-radio__icon';
        const label = document.createElement('label');
        label.className = 'citizen-client-prefs-radio__label';
        label.htmlFor = 'lt-theme-default';
        label.textContent = 'Velvet Room';
        radioWrapper.appendChild(input);
        radioWrapper.appendChild(icon);
        radioWrapper.appendChild(label);
        item.appendChild(radioWrapper);
        list.appendChild(item);
        content.appendChild(list);
        wrapper.appendChild(heading);
        wrapper.appendChild(content);
        container.appendChild(wrapper);
    }
    const observer = new MutationObserver(function () {
        const container = document.querySelector('.citizen-preferences-content');
        if (container) {
            injectThemeOption(container);
        }
    });
    observer.observe(document.body, { childList: true, subtree: true });
});

Revision as of 16:40, 20 February 2026

mw.loader.using(['mediawiki.util']).then(function () {

    function injectThemeOption(container) {

        if (document.getElementById('lt-theme-test')) return;

        const wrapper = document.createElement('div');
        wrapper.id = 'lt-theme-test';
        wrapper.className = 'mw-portlet citizen-menu';

        const heading = document.createElement('div');
        heading.className = 'citizen-menu__heading';
        heading.textContent = 'Theme';

        const content = document.createElement('div');
        content.className = 'citizen-menu__content';

        const list = document.createElement('ul');
        list.className = 'citizen-menu__content-list';

        const item = document.createElement('li');
        item.className = 'mw-list-item mw-list-item-js';

        const radioWrapper = document.createElement('div');
        radioWrapper.className = 'citizen-client-prefs-radio';

        const input = document.createElement('input');
        input.type = 'radio';
        input.name = 'lt-theme-group';
        input.id = 'lt-theme-default';
        input.className = 'citizen-client-prefs-radio__input';

        const icon = document.createElement('span');
        icon.className = 'citizen-client-prefs-radio__icon';

        const label = document.createElement('label');
        label.className = 'citizen-client-prefs-radio__label';
        label.htmlFor = 'lt-theme-default';
        label.textContent = 'Velvet Room';

        radioWrapper.appendChild(input);
        radioWrapper.appendChild(icon);
        radioWrapper.appendChild(label);

        item.appendChild(radioWrapper);
        list.appendChild(item);
        content.appendChild(list);

        wrapper.appendChild(heading);
        wrapper.appendChild(content);

        container.appendChild(wrapper);
    }

    const observer = new MutationObserver(function () {
        const container = document.querySelector('.citizen-preferences-content');
        if (container) {
            injectThemeOption(container);
        }
    });

    observer.observe(document.body, { childList: true, subtree: true });

});