console.log("loading config for themarysue");window.gamursInfScrollCustomSiteConfig={site:"themarysue",useCategories:true,useTags:true,categories:undefined,tags:undefined};window.gamursInfScroll={infScrollURL:"https://infinite-scroll-system.gamurs.workers.dev"};console.log("Infinite scroll initialised");(function(){var O,E,$,T;let s=window.gamursInfScrollCustomSiteConfig,h=window.gamursInfScroll,x=s&&(O=s.categories)!=null?O:"",M=s&&(E=s.tags)!=null?E:"",R=!(s&&s.useCategories===!1),L=!(s&&s.useTags===!1),w=h&&($=h.infScrollURL)!=null?$:"",y=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-categories"].value,S=document.getElementsByClassName("gamurs-inf-scroll-post")[0].attributes["data-tags"].value,v=document.getElementsByClassName("gamurs-inf-scroll-post")[0].dataset.id,n=window.location.hostname.split(".")[window.location.hostname.split(".").length-2];n==="lndo"?n=window.location.hostname.split(".")[0]:n==="go-vip"&&(n=window.location.hostname.split(".")[0],n=n.split("-")[0],n==="www"&&(n=window.location.hostname.split(".")[0].split("-")[1]));let a=`${w}/infscroll/${n}/${v}?categories=${y}&tags=${S}&useCategories=${R}&useTags=${L}&forceCategories=${x}&forceTags=${M}`,U={root:document.querySelector("#scroll-area"),rootMargin:"0px",threshold:.5},N={rootMargin:"-50% 0% -50% 0%",threshold:0},j={rootMargin:"-50% 0% -10% 0%",threshold:0};function A(t,o,l){let e;return l==="middle"?(e=new IntersectionObserver(o,N),e=i(t,e,!1)):l==="middleofmiddle"?(e=new IntersectionObserver(o,j),e=i(t,e,!0)):(e=new IntersectionObserver(o,U),e=i(t,e,!1)),e}function b(t){if(typeof window.gamursInfScrollOnInfiniteScrollAppend=="function")try{window.gamursInfScrollOnInfiniteScrollAppend(t)}catch(o){console.log(o)}}function B(t,o){t[0].isIntersecting&&(g(),o.unobserve(t[0].target))}function i(t,o,l){let e;return l?(t.style.position="relative",e=document.createElement("div"),e.style.position="absolute",e.style.top="50%",e.style.width="100%",e.style.height="1px",t.appendChild(e)):e=t,o.observe(e),o}let c=[],u=document.querySelector(".gamurs-inf-scroll-post");c[u&&(T=u.dataset.id)!=null?T:0]=document.URL;let q=!1;history.scrollRestoration="manual";let f=!0,C=0;function J(t,o){t.forEach(l=>{if(l.isIntersecting&&window.location.href!==l.target.dataset.url){let e=c[l.target.dataset.id];if(l.boundingClientRect.y>C?history.pushState(null,"",e):(f=!1,history.back()),document.title=l.target.dataset.title,typeof window.gamursInfScrollOnUrlChange=="function")try{window.gamursInfScrollOnUrlChange(e)}catch(r){console.log(r)}window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"impression"})}C=l.boundingClientRect.y}),Array.from(document.getElementsByClassName("gamurs-inf-scroll-post")).map(l=>o.observe(l))}addEventListener("popstate",t=>{try{f&&document.querySelector(`[data-url="${t.target.location.href.split("?")[0]}"]`).scrollIntoView()}catch(o){console.log(o)}f=!0});function g(){q?fetch(a).then(t=>{if(t.status!==200)throw`request failed: ${t.text()}`;return t.json()}).then(function(o){let l=o;if(l.html!=null){c[l.id]=l.url,a=l.nextUrl;let e=document.createElement("div");e.innerHTML=l.html;let r=document.querySelector("#gamurs-inf-scroll-main");if(r)r.appendChild(e);else throw"did not find #gamurs-inf-scroll-main";Array.from(e.querySelectorAll("script")).forEach(m=>{try{(0,eval)(m.innerText)}catch(p){console.log(p)}}),b(l.id),i(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],d,!0),i(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],I,!1),d.unobserve(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-2])}}).catch(t=>{let o=a.split("?")[1].split("&").filter(e=>e.slice(0,5)==="page="),l=o.length?parseInt(o[0].split("=")[1]):1;if(l<20){if(t.slice(0,15)==="request failed:"){let e=a.split("?");a=e[0]+"?page="+(l+1).toString()+"&"+e[1].split("&").filter(r=>r.slice(0,5)!=="page=").join("&")}t!=="did not find #gamurs-inf-scroll-main"&&g()}}):(q=!0,fetch(`${w}/campaign/${n}/${v}?categories=${y}&tags=${S}`).then(t=>{if(t.status!==200)throw"No Campaign";return t.json()}).then(function(o){let l=o;if(l.html!=null){c[l.id]=l.url;let e=document.createElement("div");e.innerHTML=l.html;let r=document.querySelector("#gamurs-inf-scroll-main");if(r)r.appendChild(e);else throw"did not find #gamurs-inf-scroll-main";window.snowplow&&window.snowplow("trackStructEvent",{category:"gamurs-infinite-scroll",action:"append-article",label:l.id}),Array.from(e.querySelectorAll("script")).forEach(m=>{try{(0,eval)(m.innerText)}catch(p){console.log(p)}}),b(l.id),i(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],d,!0),i(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-1],I,!1),d.unobserve(document.querySelectorAll(".gamurs-inf-scroll-post")[document.querySelectorAll(".gamurs-inf-scroll-post").length-2].lastChild)}}).catch(t=>{console.log(t),t!=="did not find #gamurs-inf-scroll-main"&&g()}))}let I=A(u,J,"middle"),d=A(u,B,"middleofmiddle")})();
