MediaWiki:Citizen.js

MediaWiki interface page
Revision as of 01:02, 15 October 2023 by Quenty (talk | contribs) (Created page with "$(document).ready(function() { // Check if the user is not logged in if (mw.user.isAnon()) { // Select the elements with the specified class var elements = $('.oo-ui-buttonElement-button'); // Iterate through the selected elements elements.each(function() { var $element = $(this); // Check if aria-disabled is set to "true" if ($element.attr('aria-disabled') === 'true') { // Crea...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
$(document).ready(function() {
    // Check if the user is not logged in
    if (mw.user.isAnon()) {
        // Select the elements with the specified class
        var elements = $('.oo-ui-buttonElement-button');

        // Iterate through the selected elements
        elements.each(function() {
            var $element = $(this);

            // Check if aria-disabled is set to "true"
            if ($element.attr('aria-disabled') === 'true') {
                // Create a new HTML snippet with MediaWiki links
                var loginMessage = '<p>Please <a href="/wiki/Special:UserLogin">login</a> or <a href="/wiki/Special:CreateAccount">sign up</a> to continue.</p>';

                // Insert the message after the disabled button
                $element.after(loginMessage);
            }
        });
    }
});