Version 0.1.0.
Added infinite scroll to the public Forum threads, and added options page to adjust whether to enable infinite scrolling in thread lists and inside threads separately.
diff --git a/console_inject.js b/console_inject.js
index 0cfbeae..2bc6f15 100644
--- a/console_inject.js
+++ b/console_inject.js
@@ -1,12 +1,14 @@
+var mutationObserver, intersectionObserver, options;
+
function mutationCallback(mutationList, observer) {
mutationList.forEach((mutation) => {
if (mutation.type == "childList") {
mutation.addedNodes.forEach(function (node) {
- if ((typeof node.classList !== "undefined") && node.classList.contains("view-more-button-container")) {
+ if (options.list && (typeof node.classList !== "undefined") && node.classList.contains("view-more-button-container")) {
intersectionObserver.observe(node.querySelector(".view-more-button"));
}
- if ((typeof node.classList !== "undefined") && node.classList.contains("load-more-bar")) {
+ if (options.thread && (typeof node.classList !== "undefined") && node.classList.contains("load-more-bar")) {
intersectionObserver.observe(node.querySelector(".load-more-button"));
}
});
@@ -28,13 +30,17 @@
subtree: true
}
-var mutationObserver = new MutationObserver(mutationCallback);
-mutationObserver.observe(document.querySelector(".scrollable-content"), observerOptions);
-
var intersectionOptions = {
root: document.querySelector('.scrollable-content'),
rootMargin: '0px',
threshold: 1.0
}
-var intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+chrome.storage.sync.get(null, function(items) {
+ options = items;
+
+ mutationObserver = new MutationObserver(mutationCallback);
+ mutationObserver.observe(document.querySelector(".scrollable-content"), observerOptions);
+
+ intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions);
+});