avm99963 | a92652e | 2020-08-31 22:05:10 +0200 | [diff] [blame] | 1 | var CCRegex = /^https:\/\/support\.google\.com\/s\/community/; |
| 2 | if (!CCRegex.test(location.href)) { |
| 3 | var intersectionObserver; |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 4 | |
avm99963 | a92652e | 2020-08-31 22:05:10 +0200 | [diff] [blame] | 5 | 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 | } |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 43 | } |
| 44 | }); |
avm99963 | a92652e | 2020-08-31 22:05:10 +0200 | [diff] [blame] | 45 | } |