blob: c3b484ef90c2fb690e8051c331c008b47bec68bd [file] [log] [blame]
avm99963cbea3142019-03-28 00:48:15 +01001var intersectionObserver;
2
3function intersectionCallback(entries, observer) {
4 entries.forEach(entry => {
5 if (entry.isIntersecting) {
6 entry.target.click();
7 }
8 });
9};
10
11var intersectionOptions = {
12 threshold: 1.0
13}
14
15chrome.storage.sync.get(null, function(items) {
avm999637db655f2020-08-18 11:44:31 +020016 var path = document.location.pathname.split("/");
17 if (path[path.length - 1] == "new" ||
18 (path.length > 1 && path[path.length - 1] == "" &&
19 path[path.length - 2] == "new")) {
20 return;
21 }
22
avm99963adf90862020-04-12 13:27:45 +020023 var redirectLink = document.querySelector(".community-console");
avm99963134f1ef2019-03-30 19:05:27 +010024 if (items.redirect && redirectLink !== null) {
25 window.location = redirectLink.href;
26 } else {
avm999637db655f2020-08-18 11:44:31 +020027 var button =
28 document.querySelector(".thread-all-replies__load-more-button");
avm99963134f1ef2019-03-30 19:05:27 +010029 if (items.thread && button !== null) {
avm999637db655f2020-08-18 11:44:31 +020030 intersectionObserver =
31 new IntersectionObserver(intersectionCallback, intersectionOptions);
avm99963134f1ef2019-03-30 19:05:27 +010032 intersectionObserver.observe(button);
33 }
avm999637db655f2020-08-18 11:44:31 +020034 var allbutton =
35 document.querySelector(".thread-all-replies__load-all-button");
avm999636d9c5fe2019-06-04 00:35:53 +020036 if (items.threadall && button !== null) {
avm999637db655f2020-08-18 11:44:31 +020037 intersectionObserver =
38 new IntersectionObserver(intersectionCallback, intersectionOptions);
avm999636d9c5fe2019-06-04 00:35:53 +020039 intersectionObserver.observe(allbutton);
40 }
avm99963cbea3142019-03-28 00:48:15 +010041 }
42});