MediaWiki:Citizen.js: Difference between revisions

MediaWiki interface page
No edit summary
No edit summary
Line 20: Line 20:
 
});
 
});
 
}
 
}
  +
}, 250);
}, 2000); // Delay for 2 seconds (adjust as needed)
 
 
});
 
});

Revision as of 01:19, 15 October 2023

$(document).ready(function() {
    setTimeout(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);
                }
            });
        }
    }, 250);
});