No edit summary |
No edit summary |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
$(document).ready(function() { |
$(document).ready(function() { |
||
| + | setTimeout(function() { |
||
| − | // Check if the user is not logged in |
||
| − | if (mw.user.isAnon()) { |
+ | if (mw.user.isAnon()) { |
| − | var |
+ | var elements = $('.cs-header > .oo-ui-widget-disabled'); |
| − | // Select the elements with the specified class |
||
| − | var elements = $('.oo-ui-buttonElement-button'); |
||
| − | |||
| − | // Iterate through the selected elements |
||
elements.each(function() { |
elements.each(function() { |
||
var $element = $(this); |
var $element = $(this); |
||
| ⚫ | |||
| − | |||
| − | + | $element.after(loginMessage); |
|
| − | if ($element.attr('aria-disabled') === 'true') { |
||
| − | // Create a new HTML snippet with MediaWiki links |
||
| ⚫ | |||
| − | |||
| − | // Check if the message is already present to avoid duplication |
||
| − | if (!$element.next().hasClass('login-message')) { |
||
| − | // Insert the message after the disabled button |
||
| − | $element.after(loginMessage); |
||
| − | } |
||
| − | } |
||
}); |
}); |
||
| − | } |
+ | } |
| ⚫ | |||
| − | |||
| − | // Initial check |
||
| − | handleElements(); |
||
| − | |||
| − | // Use delegated event handling to handle dynamically added elements |
||
| − | $(document).on('DOMNodeInserted', function(event) { |
||
| − | var target = $(event.target); |
||
| − | |||
| − | // Check if the target has the specified class |
||
| − | if (target.hasClass('oo-ui-buttonElement-button')) { |
||
| − | handleElements(); |
||
| − | } |
||
| ⚫ | |||
| − | } |
||
}); |
}); |
||
Latest revision as of 01:31, 15 October 2023
$(document).ready(function() {
setTimeout(function() {
if (mw.user.isAnon()) {
var elements = $('.cs-header > .oo-ui-widget-disabled');
elements.each(function() {
var $element = $(this);
var loginMessage = '<p style="cs-custom-login-prompt">Please <a href="/wiki/Special:UserLogin">login</a> or <a href="/wiki/Special:CreateAccount">sign up</a> to continue.</p>';
$element.after(loginMessage);
});
}
}, 250);
});