blob: 90eb421b891dc640ed8854dfc2e9685aaa06d860 [file] [log] [blame]
avm99963a92652e2020-08-31 22:05:10 +02001var CCRegex = /^https:\/\/support\.google\.com\/s\/community/;
2if (!CCRegex.test(location.href)) {
3 var intersectionObserver;
avm99963cbea3142019-03-28 00:48:15 +01004
avm99963a92652e2020-08-31 22:05:10 +02005 function intersectionCallback(entries, observer) {
6 entries.forEach(entry => {
7 if (entry.isIntersecting) {
8 entry.target.click();
9 }
10 });
11 };
12
13 var intersectionOptions = {
14 threshold: 1.0,
15 };
16
17 chrome.storage.sync.get(null, function(items) {
18 var path = document.location.pathname.split('/');
19 if (path[path.length - 1] == 'new' ||
20 (path.length > 1 && path[path.length - 1] == '' &&
21 path[path.length - 2] == 'new')) {
22 return;
23 }
24
25 var redirectLink = document.querySelector('.community-console');
26 if (items.redirect && redirectLink !== null) {
27 window.location = redirectLink.href;
28 } else {
29 var button =
30 document.querySelector('.thread-all-replies__load-more-button');
31 if (items.thread && button !== null) {
32 intersectionObserver =
33 new IntersectionObserver(intersectionCallback, intersectionOptions);
34 intersectionObserver.observe(button);
35 }
36 var allbutton =
37 document.querySelector('.thread-all-replies__load-all-button');
38 if (items.threadall && button !== null) {
39 intersectionObserver =
40 new IntersectionObserver(intersectionCallback, intersectionOptions);
41 intersectionObserver.observe(allbutton);
42 }
avm99963cbea3142019-03-28 00:48:15 +010043 }
44 });
avm99963a92652e2020-08-31 22:05:10 +020045}