PageSourceSearch

https://labelleboucle.fr/cdn/shop/t/258/assets/nosto-cart-sync.js?v=173974884348286447571784203673

js labelleboucle.fr collected 2026-10-03 21:22:05 UTC 4,594 bytes, 2 lines download raw bytes

1(function(){if(typeof window>"u"||window.__nostoCartSyncInstalled)return;window.__nostoCartSyncInstalled=!0;const DEBOUNCE_MS=300,CART_MUTATION_SUFFIXES=["cart/add","cart/change","cart/update","cart/clear"];let pendingAttribution=null;const ATTRIBUTION_TTL_MS=3e4;function syncNostoCart(){window.Nosto&&typeof window.Nosto.reloadCart=="function"&&Promise.resolve(window.Nosto.reloadCart()).catch(function(err){console.warn("[NostoCartSync] Nosto.reloadCart failed:",err)})}let attrTimer=null;function scheduleAttribution(){attrTimer&&clearTimeout(attrTimer),attrTimer=setTimeout(function(){attrTimer=null;try{if(pendingAttribution&&Date.now()-pendingAttribution.ts<ATTRIBUTION_TTL_MS){const attr=pendingAttribution;pendingAttribution=null,typeof window.nostojs=="function"&&window.nostojs(function(api){const fn=api.recommendedProductAddedToCart||api.reportAddToCart;if(typeof fn=="function")try{fn.call(api,attr.productId,attr.placement)}catch(err){console.warn("[NostoCartSync] attribution failed:",err)}})}else pendingAttribution=null}catch(err){console.warn("[NostoCartSync] attribution block failed:",err)}},DEBOUNCE_MS)}let syncTimer=null;function scheduleSync(){syncTimer&&clearTimeout(syncTimer),syncTimer=setTimeout(function(){syncTimer=null,syncNostoCart()},DEBOUNCE_MS)}let lastCartSig=null;function cartSignature(){const el=document.querySelector(".nosto_cart");if(!el)return null;const restore=el.querySelector(".restore_link");return(restore?restore.textContent:el.textContent).replace(/\s+/g,"")}let sigCheckTimer=null;function onDomMutated(){sigCheckTimer||(sigCheckTimer=setTimeout(function(){sigCheckTimer=null;const sig=cartSignature();sig!==null&&sig!==lastCartSig&&(lastCartSig=sig,scheduleSync())},120))}function installCartTaggingObserver(){if(typeof MutationObserver!="function")return;lastCartSig=cartSignature(),new MutationObserver(onDomMutated).observe(document.body,{childList:!0,subtree:!0,characterData:!0})}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",installCartTaggingObserver):installCartTaggingObserver();function resolveAttribution(el){if(!el)return null;const surface=el.closest&&el.closest("[data-nosto-placement]");if(!surface)return null;const placement=surface.getAttribute("data-nosto-placement");if(!placement)return null;let productId=null;const slide=el.closest("[data-nosto-product-id]");if(slide&&(productId=slide.getAttribute("data-nosto-product-id")),!productId){const card=el.closest("[data-product-id]");card&&(productId=card.getAttribute("data-product-id"))}return productId?{productId:String(productId),placement,ts:Date.now()}:null}document.addEventListener("click",function(e){try{const attr=resolveAttribution(e.target);attr&&(pendingAttribution=attr)}catch{}},!0),document.addEventListener("submit",function(e){try{const form=e.target;if(!form||form.tagName!=="FORM")return;const action=form.getAttribute("action")||"";if(!/\/cart\/add(?:\.js)?(?:[?#]|$)/.test(action))return;const attr=resolveAttribution(form);attr&&(pendingAttribution=attr)}catch{}},!0);function getRoot(){return(window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root||"/").replace(/\/+$/,"")}function isCartMutation(url,method){if(!url||(method||"GET").toUpperCase()!=="POST")return!1;try{const u=new URL(url,window.location.origin);if(u.origin!==window.location.origin)return!1;const path=u.pathname.replace(/\.js$/,"").replace(/\/+$/,""),root=getRoot();if(root&&!path.startsWith(root+"/")&&path!==root)return!1;const suffix=root?path.slice(root.length+1):path.replace(/^\//,"");return CART_MUTATION_SUFFIXES.indexOf(suffix)!==-1}catch{return!1}}const origFetch=window.fetch;window.fetch=function(input,init){const url=typeof input=="string"?input:input&&input.url||"",method=init&&init.method||input&&input.method||"GET",promise=origFetch.apply(this,arguments);return isCartMutation(url,method)&&promise.then(function(response){response&&response.ok&&scheduleAttribution()}).catch(function(){}),promise};const origOpen=XMLHttpRequest.prototype.open,origSend=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(method,url){try{this.__nostoCartUrl=url,this.__nostoCartMethod=method}catch{}return origOpen.apply(this,arguments)},XMLHttpRequest.prototype.send=function(){const url=this.__nostoCartUrl,method=this.__nostoCartMethod;return url&&isCartMutation(url,method)&&this.addEventListener("load",function(){this.status>=200&&this.status<300&&scheduleAttribution()}),origSend.apply(this,arguments)}})();
2//# sourceMappingURL=/cdn/shop/t/258/assets/nosto-cart-sync.js.map?v=173974884348286447571784203673

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.