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) { |
| 5 | if ((typeof node.classList !== "undefined") && node.classList.contains("view-more-button-container")) { |
| 6 | intersectionObserver.observe(node.querySelector(".view-more-button")); |
| 7 | } |
| 8 | }); |
| 9 | } |
| 10 | }); |
| 11 | } |
| 12 | |
| 13 | function intersectionCallback(entries, observer) { |
| 14 | entries.forEach(entry => { |
| 15 | if (entry.isIntersecting) { |
| 16 | entry.target.click(); |
| 17 | } |
| 18 | }); |
| 19 | }; |
| 20 | |
| 21 | var observerOptions = { |
| 22 | childList: true, |
| 23 | attributes: true, |
| 24 | subtree: true |
| 25 | } |
| 26 | |
| 27 | var mutationObserver = new MutationObserver(mutationCallback); |
| 28 | mutationObserver.observe(document.querySelector(".scrollable-content"), observerOptions); |
| 29 | |
| 30 | var intersectionOptions = { |
| 31 | root: document.querySelector('.scrollable-content'), |
| 32 | rootMargin: '0px', |
| 33 | threshold: 1.0 |
| 34 | } |
| 35 | |
| 36 | var intersectionObserver = new IntersectionObserver(intersectionCallback, intersectionOptions); |