avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 1 | var intersectionObserver; |
| 2 | |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 3 | function intersectionCallback(entries, observer) { |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 4 | entries.forEach(entry => { |
| 5 | if (entry.isIntersecting) { |
| 6 | entry.target.click(); |
| 7 | } |
| 8 | }); |
| 9 | }; |
| 10 | |
| 11 | var intersectionOptions = { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 12 | threshold: 1.0, |
| 13 | }; |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 14 | |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 15 | chrome.storage.sync.get(null, function(items) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 16 | var button = document.querySelector('.thread-list-threads__load-more-button'); |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 17 | if (items.list && button !== null) { |
avm99963 | b69eb3d | 2020-08-20 02:03:44 +0200 | [diff] [blame] | 18 | intersectionObserver = |
| 19 | new IntersectionObserver(intersectionCallback, intersectionOptions); |
avm99963 | cbea314 | 2019-03-28 00:48:15 +0100 | [diff] [blame] | 20 | intersectionObserver.observe(button); |
| 21 | } |
| 22 | }); |