avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 1 | function mutationCallback(mutationList, observer) { |
| 2 | mutationList.forEach((mutation) => { |
| 3 | if (mutation.type == "childList") { |
| 4 | mutation.addedNodes.forEach(function (node) { |
avm99963 | 5fe510b | 2019-03-27 01:23:06 +0100 | [diff] [blame] | 5 | if ((typeof node.classList !== "undefined") && node.classList.contains("view-more-button-container")) { |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 6 | intersectionObserver.observe(node.querySelector(".view-more-button")); |
| 7 | } |
Nico Sinisterra | 4ae1c57 | 2019-03-27 12:57:13 -0300 | [diff] [blame^] | 8 | |
| 9 | if ((typeof node.classList !== "undefined") && node.classList.contains("load-more-bar")) { |
| 10 | intersectionObserver.observe(node.querySelector(".load-more-button")); |
| 11 | } |
avm99963 | 847ee63 | 2019-03-27 00:57:44 +0100 | [diff] [blame] | 12 | }); |
| 13 | } |
| 14 | }); |
| 15 | } |
| 16 | |
| 17 | function intersectionCallback(entries, observer) { |
| 18 | entries.forEach(entry => { |
| 19 | if (entry.isIntersecting) { |
| 20 | entry.target.click(); |
| 21 | } |
| 22 | }); |
| 23 | }; |
| 24 | |
| 25 | var observerOptions = { |
| 26 | childList: true, |
| 27 | attributes: true, |
| 28 | subtree: true |
| 29 | } |
| 30 | |
| 31 | var mutationObserver = new MutationObserver(mutationCallback); |
| 32 | mutationObserver.observe(document.querySelector(".scrollable-content"), observerOptions); |
| 33 | |
| 34 | var intersectionOptions = { |
| 35 | root: document.querySelector('.scrollable-content'), |
| 36 | rootMargin: '0px', |
| 37 | threshold: 1.0 |
| 38 | } |
| 39 | |
avm99963 | 5fe510b | 2019-03-27 01:23:06 +0100 | [diff] [blame] | 40 | var intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions); |