PageSourceSearch

https://pigandhen.nl/cdn/shop/t/3/assets/bbd-market-suggestion-modal.js?v=55722732365268391541780481337

js pigandhen.nl collected 2026-10-01 06:57:47 UTC 6,350 bytes, 2 lines download raw bytes

1class BbdMarketSuggestionModal extends HTMLElement{#dialog=null;#config=null;#previousScrollY=0;connectedCallback(){try{const configEl=document.getElementById("MarketSuggestionModalConfig");if(!configEl)return;this.#config=JSON.parse(configEl.textContent),this.#dialog=this.querySelector("dialog"),this.#interceptLocalizationForms(),this.#init()}catch{}}async#init(){try{const params=new URLSearchParams(window.location.search),uaBypass=/BbdEndtest/i.test(navigator.userAgent),cookieBypass=/(?:^|;\s*)bbdNoMarketModal=1(?:;|$)/.test(document.cookie);if(uaBypass||params.get("bbdNoMarketModal")==="1"||cookieBypass||window.Shopify?.designMode||window.Shopify?.visualPreviewMode||sessionStorage.getItem("marketSuggestionAutoRedirected")==="1"||sessionStorage.getItem("marketSuggestionModalDismissed")==="1")return;const{currentCountry,currentLanguage}=this.#config,root=window.Shopify?.routes?.root||"/",url=new URL(root+"browsing_context_suggestions.json",window.location.origin);url.searchParams.set("country[enabled]","true"),url.searchParams.set("language[enabled]","true"),currentCountry&&url.searchParams.set("country[exclude]",currentCountry),currentLanguage&&url.searchParams.set("language[exclude]",currentLanguage);const res=await fetch(url.toString(),{credentials:"same-origin"});if(!res.ok)return;const suggestion=(await res.json()).suggestions?.[0];if(!suggestion)return;const suggestedCountry=suggestion.parts?.country?.handle,suggestedCountryName=suggestion.parts?.country?.name,suggestedLanguage=suggestion.parts?.language?.handle;if(!suggestedCountry||suggestedCountry.toUpperCase()===currentCountry.toUpperCase())return;const uppercasedCountry=suggestedCountry.toUpperCase(),englishCountryName=(()=>{try{return new Intl.DisplayNames(["en"],{type:"region"}).of(uppercasedCountry)||suggestedCountryName}catch{return suggestedCountryName}})(),manualMarket=localStorage.getItem("marketSuggestionManualMarket");this.#config.autoRedirect&&!manualMarket?this.#redirect(uppercasedCountry,suggestedLanguage):(this.#populate(uppercasedCountry,englishCountryName,suggestedLanguage),this.#openDialog())}catch{}}#interceptLocalizationForms(){const modalForm=this.querySelector(".bbd-market-suggestion-modal__form");document.querySelectorAll("form").forEach(form=>{if(form===modalForm||!form.action?.includes("/localization"))return;const nativeSubmit=HTMLFormElement.prototype.submit.bind(form);form.submit=()=>{const countryCode=form.querySelector('[name="country_code"]')?.value;if(countryCode)try{localStorage.setItem("marketSuggestionManualMarket",countryCode),localStorage.removeItem("marketSuggestionAutoRedirect")}catch{}nativeSubmit()}})}#redirect(suggestedCountry,suggestedLanguage){try{sessionStorage.setItem("marketSuggestionAutoRedirected","1"),localStorage.setItem("marketSuggestionAutoRedirect","1")}catch{}const countryInput=this.querySelector(".bbd-market-suggestion-modal__country-input"),languageInput=this.querySelector(".bbd-market-suggestion-modal__language-input"),returnToInput=this.querySelector('[name="return_to"]');countryInput&&(countryInput.value=suggestedCountry),languageInput&&(languageInput.value=suggestedLanguage||""),returnToInput&&(returnToInput.value=window.location.pathname+window.location.search),this.querySelector(".bbd-market-suggestion-modal__form")?.submit()}#populate(suggestedCountry,suggestedCountryName,suggestedLanguage){const{heading,body,acceptLabel,cancelLabel}=this.#config,titleEl=this.querySelector(".bbd-market-suggestion-modal__title"),bodyEl=this.querySelector(".bbd-market-suggestion-modal__body"),acceptBtn=this.querySelector("[data-accept]"),cancelBtn=this.querySelector("[data-cancel]"),countryInput=this.querySelector(".bbd-market-suggestion-modal__country-input"),languageInput=this.querySelector(".bbd-market-suggestion-modal__language-input");titleEl&&(titleEl.textContent=heading),bodyEl&&(bodyEl.textContent=body.replace("{country}",suggestedCountryName||suggestedCountry)),acceptBtn&&(acceptBtn.textContent=acceptLabel),cancelBtn&&(cancelBtn.textContent=cancelLabel),countryInput&&(countryInput.value=suggestedCountry),languageInput&&(languageInput.value=suggestedLanguage||""),cancelBtn?.addEventListener("click",()=>this.#cancel()),acceptBtn?.addEventListener("click",()=>this.#accept()),this.#dialog?.addEventListener("click",event=>{event.target===this.#dialog&&this.#cancel()}),this.#dialog?.addEventListener("cancel",event=>{event.preventDefault(),this.#cancel()})}#openDialog(){if(!this.#dialog||this.#dialog.open)return;const scrollY=window.scrollY;this.#previousScrollY=scrollY,requestAnimationFrame(()=>{document.documentElement.setAttribute("scroll-lock",""),document.body.style.width="100%",document.body.style.position="fixed",document.body.style.top=`-${scrollY}px`,this.#dialog.showModal(),this.querySelector("[data-accept]")?.focus()})}#cancel(){try{sessionStorage.setItem("marketSuggestionModalDismissed","1")}catch{}this.#closeDialog()}#accept(){try{localStorage.setItem("marketSuggestionAutoRedirect","1"),localStorage.removeItem("marketSuggestionManualMarket")}catch{}const returnToInput=this.querySelector('[name="return_to"]');returnToInput&&(returnToInput.value=window.location.pathname+window.location.search),this.querySelector(".bbd-market-suggestion-modal__form")?.submit()}async#closeDialog(){if(!this.#dialog?.open)return;this.#dialog.classList.add("dialog-closing"),await new Promise(resolve=>{this.#dialog.addEventListener("animationend",resolve,{once:!0}),setTimeout(resolve,300)});const otherOpenDialogs=Array.from(document.querySelectorAll("dialog[open]")).filter(d=>d!==this.#dialog),activeLockers=Array.from(document.querySelectorAll("[scroll-lock]:not(html)")).filter(el=>el.tagName==="DIALOG"?!1:el.tagName==="DETAILS"?el.open:el.offsetWidth>0&&el.offsetHeight>0);
1otherOpenDialogs.length===0&&activeLockers.length===0&&(document.documentElement.removeAttribute("scroll-lock"),document.body.style.width="",document.body.style.position="",document.body.style.top="",window.scrollTo({top:this.#previousScrollY,behavior:"instant"})),this.#dialog.close(),this.#dialog.classList.remove("dialog-closing")}}customElements.get("bbd-market-suggestion-modal")||customElements.define("bbd-market-suggestion-modal",BbdMarketSuggestionModal);
2//# sourceMappingURL=/cdn/shop/t/3/assets/bbd-market-suggestion-modal.js.map?v=55722732365268391541780481337

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.