PageSourceSearch

https://kingsloot.com/cdn/shop/t/499/assets/variant-hide-swatches.js?v=104164175987722207061771097085

js kingsloot.com collected 2026-10-04 17:26:47 UTC 3,178 bytes, 2 lines download raw bytes

1(()=>{if(!(document.body.classList.contains("template-product")||location.pathname.startsWith("/products/")))return;const norm=s=>(s||"").replace(/\s+/g," ").trim(),parseJSON=el=>{try{return JSON.parse(el.textContent||"null")}catch{return null}},getVariantsFromRoot=root=>{const el=root.querySelector('script[type="application/json"]'),data=el?parseJSON(el):null;return Array.isArray(data)?data:null},getHideMap=()=>{const el=document.querySelector('script[id^="variant-hide-map-"]'),data=el?parseJSON(el):null;return data&&typeof data=="object"?data:null},getSelectedOptionsByName=root=>{const map={};return root.querySelectorAll("fieldset.product-form__input").forEach(fs=>{const input=fs.querySelector('input[type="radio"]:checked');if(!input)return;const baseName=(input.getAttribute("name")||"").split("-")[0];map[baseName]=norm(input.value)}),map},findVariantForColor=(variants,selectedMap,colorValue)=>{const desiredColor=norm(colorValue),desired={...selectedMap,Color:desiredColor,color:desiredColor},matches=v=>{if(Array.isArray(v.options)&&v.options.length){if(norm(v.options[0])!==desiredColor)return!1;const styleSel2=selectedMap.Style||selectedMap.style;if(styleSel2&&!v.options.some(x=>norm(x)===norm(styleSel2)))return!1;const ringSel=selectedMap["Ring Type"]||selectedMap["ring type"];return!(ringSel&&!v.options.some(x=>norm(x)===norm(ringSel)))}if(norm(v.option1)!==desiredColor)return!1;const styleSel=selectedMap.Style||selectedMap.style;return!(styleSel&&v.option2&&norm(v.option2)!==norm(styleSel))};return variants.find(matches)||variants.find(v=>norm(v.option1)===desiredColor)||null},applyToRoot=(root,variants,hideMap)=>{const colorFieldset=root.querySelector("fieldset.product-form__input.Color");if(!colorFieldset)return;const selectedMap=getSelectedOptionsByName(root),colorInputs=[...colorFieldset.querySelectorAll('input.colors-js[type="radio"]')];colorInputs.forEach(input=>{const label=colorFieldset.querySelector(`label[for="${CSS.escape(input.id)}"]`),v=findVariantForColor(variants,selectedMap,input.value),id=v?.id?String(v.id):null,shouldHide=id?hideMap[id]===!0:!1;if(input.disabled=shouldHide,label&&(shouldHide?label.style.setProperty("display","none","important"):label.style.removeProperty("display")),shouldHide&&input.checked){const next=colorInputs.find(i=>{const vv=findVariantForColor(variants,selectedMap,i.value),iid=vv?.id?String(vv.id):null;return iid?hideMap[iid]!==!0:!0});next&&next!==input&&next.click()}})},init=()=>{const hideMap=getHideMap();hideMap&&document.querySelectorAll("variant-radios").forEach(root=>{if(root.dataset.hideSwatchesInit==="1")return;const variants=getVariantsFromRoot(root);if(!variants)return;root.dataset.hideSwatchesInit="1";const run=()=>applyToRoot(root,variants,hideMap);run(),root.addEventListener("change",e=>{const t=e.target;t&&t.matches&&t.matches('fieldset.product-form__input input[type="radio"]')&&run()}),new MutationObserver(()=>run()).observe(root,{childList:!0,subtree:!0})})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/499/assets/variant-hide-swatches.js.map?v=104164175987722207061771097085

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.