blob: 984774e1e73247758e7fa2e37792d552464badcb [file] [log] [blame]
avm9996336b8dbc2020-09-01 21:16:19 +02001var intersectionObserver;
avm99963cbea3142019-03-28 00:48:15 +01002
avm9996336b8dbc2020-09-01 21:16:19 +02003function intersectionCallback(entries, observer) {
4 entries.forEach(entry => {
5 if (entry.isIntersecting) {
6 entry.target.click();
avm99963cbea3142019-03-28 00:48:15 +01007 }
8 });
avm9996336b8dbc2020-09-01 21:16:19 +02009};
10
11var intersectionOptions = {
12 threshold: 1.0,
13};
14
15chrome.storage.sync.get(null, function(items) {
16 var redirectLink = document.querySelector('.community-console');
17 if (items.redirect && redirectLink !== null) {
18 window.location = redirectLink.href;
19 } else {
20 var button =
21 document.querySelector('.thread-all-replies__load-more-button');
22 if (items.thread && button !== null) {
23 intersectionObserver =
24 new IntersectionObserver(intersectionCallback, intersectionOptions);
25 intersectionObserver.observe(button);
26 }
27 var allbutton =
28 document.querySelector('.thread-all-replies__load-all-button');
29 if (items.threadall && button !== null) {
30 intersectionObserver =
31 new IntersectionObserver(intersectionCallback, intersectionOptions);
32 intersectionObserver.observe(allbutton);
33 }
34 }
35});