PageSourceSearch

https://paperlike.com/cdn/shop/t/223/assets/utm-campaign-popup.js?v=66081646670744308141789628640

js paperlike.com collected 2026-10-02 16:15:53 UTC 3,313 bytes, 2 lines download raw bytes

1if(!window.customElements.get("utm-campaign-popup")){class UtmCampaignPopup extends HTMLElement{constructor(){super()}connectedCallback(){this.utmCampaignParameter=this.dataset.campaignParameter,this.delay=parseInt(this.dataset.popupDelay),this.locale=this.dataset.locale,this.triggerPages=this.dataset.triggerPages?JSON.parse(this.dataset.triggerPages):[],this.waitForConsent(()=>this.init())}waitForConsent(callback){let consentHandled=!1,pollTimer=null;const hasConsent=()=>{const cookie=document.cookie.split("; ").find(c=>c.startsWith("_pandectes_gdpr="));if(!cookie)return!1;try{const consent=JSON.parse(atob(cookie.split("=")[1]));return consent.status==="allow"||consent.status==="custom"}catch{return!1}},fireIfConsented=()=>{consentHandled||!hasConsent()||(consentHandled=!0,pollTimer&&clearInterval(pollTimer),callback())};if(hasConsent()){consentHandled=!0,callback();return}pollTimer=setInterval(fireIfConsented,1e3),document.addEventListener("visitorConsentCollected",fireIfConsented)}init(){const utmCampaign=new URLSearchParams(window.location.search).get("offer"),currentPath=window.location.pathname,matchesOffer=utmCampaign&&utmCampaign===this.utmCampaignParameter,matchesPage=this.triggerPages.some(page=>currentPath===page||currentPath===page.replace(/\/$/,""));if(!matchesOffer&&!matchesPage)return;const storageKey=`utmCampaign:${this.utmCampaignParameter}_locale=${this.locale}`,storedValue=localStorage.getItem(storageKey),parsedTimestamp=parseInt(storedValue),isValidTimestamp=storedValue&&!isNaN(parsedTimestamp),isExpired=isValidTimestamp&&Date.now()-parsedTimestamp>720*60*60*1e3;(!storedValue||!isValidTimestamp||isExpired)&&(setTimeout(()=>{this.toggleVisibility(!0),localStorage.setItem(storageKey,Date.now().toString())},this.delay),console.log("not seen campaign"),this.handleGift()),this.closeButton=this.querySelector(".popup-modal__close"),this.closeButton&&this.closeButton.addEventListener("click",()=>this.toggleVisibility(!1)),document.addEventListener("click",event=>{this.contains(event.target)||this.toggleVisibility(!1)})}async handleGift(){if(this.variantId=this.dataset.giftVariantId,!this.variantId)this.handleCartAttributes();else{let formData={items:[{id:this.variantId,quantity:1,properties:{_utmCampaign:this.utmCampaignParameter}}]};fetch(`${Shopify.routes.root}cart/add.js`,{body:JSON.stringify(formData),method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"}}).then(response=>response.json()).then(cartResponse=>{const cartCount=document.querySelector("cart-count");cartCount&&fetch(`${Shopify.routes.root}cart.js`).then(response=>response.json()).then(cart=>{console.log("setting item count from UTM popup: ",cart.item_count),cartCount.itemCount=cart.item_count})})}}handleCartAttributes(){const payload={attributes:{_utmCampaign:this.utmCampaignParameter}};console.log(payload),fetch(`${Shopify.routes.root}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(payload)}).catch(error=>{console.error("Error adding attributes to cart:",error)})}toggleVisibility(show){this.classList.toggle("active",show)}}window.customElements.define("utm-campaign-popup",UtmCampaignPopup)}
2//# sourceMappingURL=/cdn/shop/t/223/assets/utm-campaign-popup.js.map?v=66081646670744308141789628640

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.