No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
function handleElement($element) { |
function handleElement($element) { |
||
if ($element.attr('aria-disabled') === 'true') { |
if ($element.attr('aria-disabled') === 'true') { |
||
⚫ | |||
− | $element.after( |
||
⚫ | |||
− | ); |
||
} |
} |
||
} |
} |
||
function handleMutations(mutationsList) { |
function handleMutations(mutationsList) { |
||
− | mutationsList.forEach((mutation) |
+ | mutationsList.forEach(function (mutation) { |
if (mutation.type === 'childList') { |
if (mutation.type === 'childList') { |
||
− | + | Array.prototype.forEach.call(mutation.addedNodes, function (node) { |
|
if ($(node).hasClass('oo-ui-buttonElement-button')) { |
if ($(node).hasClass('oo-ui-buttonElement-button')) { |
||
handleElement($(node)); |
handleElement($(node)); |
||
Line 25: | Line 23: | ||
} |
} |
||
− | + | var observer = new MutationObserver(handleMutations); |
|
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-disabled'] }); |
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-disabled'] }); |
||
− | $(document).ready(() |
+ | $(document).ready(function () { |
− | $('.oo-ui-buttonElement-button').each((index, element) |
+ | $('.oo-ui-buttonElement-button').each(function (index, element) { |
handleElement($(element)); |
handleElement($(element)); |
||
}); |
}); |
Revision as of 01:09, 15 October 2023
function isUserLoggedIn() {
return !mw.user.isAnon();
}
function handleElement($element) {
if ($element.attr('aria-disabled') === 'true') {
$element.after('<p>Please <a href="/wiki/Special:UserLogin">login</a> or <a href="/wiki/Special:UserSignup">sign up</a> to continue.</p>');
}
}
function handleMutations(mutationsList) {
mutationsList.forEach(function (mutation) {
if (mutation.type === 'childList') {
Array.prototype.forEach.call(mutation.addedNodes, function (node) {
if ($(node).hasClass('oo-ui-buttonElement-button')) {
handleElement($(node));
}
});
} else if (mutation.type === 'attributes' && mutation.attributeName === 'aria-disabled') {
handleElement($(mutation.target));
}
});
}
var observer = new MutationObserver(handleMutations);
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-disabled'] });
$(document).ready(function () {
$('.oo-ui-buttonElement-button').each(function (index, element) {
handleElement($(element));
});
});