-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexthooker-autoscroll.js
38 lines (31 loc) · 1.15 KB
/
texthooker-autoscroll.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// ==UserScript==
// @name Auto Scroll to Bottom on Data Change
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Scrolls to the bottom of the page when new data is added for a specific local HTML file
// @author Your Name
// @match file:///C:/Personal/Resources/Tools/Texthooker-Local-main/index.html
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to scroll to the bottom of the page
function scrollToBottom() {
window.scrollTo(0, document.body.scrollHeight);
}
// Create a MutationObserver to detect changes in the DOM
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
// Check if new nodes are added
if (mutation.addedNodes.length > 0) {
scrollToBottom();
}
});
});
// Configuration of the observer:
const config = { childList: true, subtree: true };
// Start observing the target node for configured mutations
observer.observe(document.body, config);
// Initial scroll to bottom
scrollToBottom();
})();