← back to Dw Theme Boost Fix
snippets/hide-browse-hidden.liquid
53 lines
{% comment %}
Hide browse-hidden products (Phillip Jeffries) from ALL rendered grids.
Runs repeatedly to catch Boost pagination, filtering, and AJAX loads.
{% endcomment %}
<script>
(function(){
var HIDDEN_VENDORS = ['Phillip Jeffries'];
function hideProducts() {
// Method 1: Find vendor text elements
document.querySelectorAll('.product-vendor, .product-list-item-vendor, [class*="vendor"]').forEach(function(el) {
var text = el.textContent.trim();
if (HIDDEN_VENDORS.indexOf(text) > -1) {
var card = el.closest('.product-list-item, .boost-sd__product-item, [class*="product-item"], [class*="product-card"], article, .boost-sd__product');
if (card && card.style.display !== 'none') { card.style.display = 'none'; }
}
});
// Method 2: Find product titles containing vendor name
document.querySelectorAll('.product-list-item-title a, .boost-sd__product-title a, [class*="product-title"] a, h2 a, h3 a').forEach(function(el) {
var text = el.textContent.trim();
for (var i = 0; i < HIDDEN_VENDORS.length; i++) {
if (text.indexOf(HIDDEN_VENDORS[i]) > -1) {
var card = el.closest('.product-list-item, .boost-sd__product-item, [class*="product-item"], [class*="product-card"], article, .boost-sd__product');
if (card && card.style.display !== 'none') { card.style.display = 'none'; }
break;
}
}
});
// Method 3: Check Boost's JSON data in script tags
document.querySelectorAll('[data-vendor="Phillip Jeffries"]').forEach(function(el) {
el.style.display = 'none';
});
}
// Run immediately
hideProducts();
// Run after DOM ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() { hideProducts(); });
}
// Run every 2 seconds to catch Boost pagination/AJAX loads
setInterval(hideProducts, 2000);
// MutationObserver as additional safety
var observer = new MutationObserver(function() { setTimeout(hideProducts, 100); });
observer.observe(document.body, { childList: true, subtree: true });
})();
</script>