Advertisement
ikai2

auto load more for the product list

Sep 19th, 2022
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.addEventListener("load", function () {
  2.   const loadMores = document.querySelectorAll('[data-pf-type="ProductList"] a.pf-cmIldm');
  3.   const observer = new IntersectionObserver(function (elements, observer) {
  4.     elements.forEach((element) => {
  5.       const el = element.target;
  6.       const isDisabled = el.hasAttribute("disabled");
  7.       if (element.isIntersecting && !isDisabled) {
  8.         el.click();
  9.        
  10.       } else if (isDisabled) {
  11.         observer.unobserve(el);
  12.       }
  13.     });
  14.   });
  15.   loadMores.forEach((loadMore) => {
  16.     observer.observe(loadMore);
  17.   });
  18. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement