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.
function attachModifiedClickHandler(element) {
const eventsData = $._data(element, 'events');
const handlers = eventsData && eventsData.click;
if (handlers && handlers.length > 0) {
const originalHandler = handlers[0].handler;
// Properly detach and reattach the click handler using jQuery
$(element).off('click').on('click', function(event) {
event.stopPropagation();
console.debug("intercepted click on", this);
originalHandler.call(this, event);
});
// Use native JavaScript to add the fix class
element.classList.add('FixCatTreeClick');
console.debug("attached on", element);
}
}
addOnloadHook(function() {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
const target = mutation.target;
// Check if the element has the specified class and has not already been processed
if (
mutation.attributeName === 'class' &&
target.classList.contains('CategoryTreeToggleHandlerAttached') &&
!target.classList.contains('FixCatTreeClick')
) {
attachModifiedClickHandler(target);
} else
console.debug("NOT attached on", target);
});
});
// Observe changes to attributes, specifically the 'class' attribute, throughout the document
observer.observe(document.body, {
attributes: true,
attributeFilter: ['class'],
subtree: true
});
});