← back to Dw Theme Boost Fix
assets/dw-pj-hide.js
30 lines
/* DW — hide Phillip Jeffries tiles from Boost BROWSE grids (collection pages).
PJ = pattern-number-lookup-only: never in browse. Skips /search + ?q= so an
exact pattern-number search still resolves the product. Deterministic, no fetch:
primary signal is the shared PJ logo image (PhillipJeffriesLogo*.png on every PJ
tile); also matches the product handle (dwjp-…-philip-jeffries-…, one-L) and text.
Cosmetic STOPGAP until the Boost Merchandising hide-by-vendor rule re-indexes. */
(function(){
if(/\/search/i.test(location.pathname) || /[?&]q=/i.test(location.search)) return; // browse only
var TXT=/phil+ip[\s_-]*jeffries/i; // phil(l)ip jeffries, one OR two L
function isPJ(el){
var im=el.querySelectorAll('img'),k;
for(k=0;k<im.length;k++){
var s=(im[k].getAttribute('src')||'')+' '+(im[k].getAttribute('srcset')||'')+' '+(im[k].getAttribute('alt')||'');
if(/phillipjeffries/i.test(s)) return true; // shared PJ logo placeholder
}
var a=el.querySelector('a[href*="/products/"]'), href=a?(a.getAttribute('href')||''):'';
if(/phil+ip-jeffr/i.test(href)) return true; // handle: (phil(l)ip-jeffr…)
if(TXT.test(el.textContent||'')) return true; // visible vendor/title text
return false;
}
var pend=false;
function sweep(){
var items=document.querySelectorAll('.boost-sd__product-item:not([data-dw-pj])'),i;
for(i=0;i<items.length;i++){ var el=items[i]; el.setAttribute('data-dw-pj','1'); if(isPJ(el)) el.style.display='none'; }
}
function schedule(){ if(pend)return; pend=true; requestAnimationFrame(function(){pend=false;sweep();}); }
function start(){ sweep(); new MutationObserver(schedule).observe(document.documentElement,{childList:true,subtree:true}); }
if(document.readyState!=='loading') start(); else document.addEventListener('DOMContentLoaded',start);
})();