I’m trying to create a simple tampermonkey script to scroll to the very bottom of the page in discord after switching the channel, I can’t seem to get it to scroll at all
the code currently does nothing, what I want it to do is scroll to the very bottom of the page
here’s the code I’ve tried
(function() {
'use strict';
function scrollToBottom() {
const scroller = document.querySelector('div[class*="scrollerContent-"]');
if (scroller) {
scroller.scrollTop = scroller.scrollHeight;
}
}
function setupURLChangeObserver() {
window.addEventListener('popstate', () => {
setTimeout(scrollToBottom, 500); // Delay to allow content to load
});
}
setupURLChangeObserver();
})();
(function() {
'use strict';
function simulateMouseScroll() {
const scroller = document.querySelector('div[class*="scrollerContent-"]');
if (scroller) {
for (let i = 0; i < 100; i++) {
scroller.dispatchEvent(new WheelEvent('wheel', { deltaY: 100, bubbles: true }));
}
}
}
function setupURLChangeObserver() {
window.addEventListener('popstate', () => {
setTimeout(simulateMouseScroll, 500); // Delay to allow content to load
});
}
setupURLChangeObserver();
})();
I’ve also tried scroller.scrollTo(0, maxScrollTop);