/* EQS P13-E | Consolidated Desks presentation test * Load after P10 and protected P9, Desks category only. Never Footer Master. * No writes to native price, cart, product data, or P9 editorial records. * Feature copy and verified manufacturer list prices can be added later. * Rollback: EQS_P13E.remove() (or remove script and refresh). */ (() => { 'use strict'; if (!/^\/category\/1366566-Desks(?:\.html)?\/?$/i.test(location.pathname)) return; if (window.EQS_P13E?.active) return; // Do not stack with P13-C or its temporary P13-D patch. if (window.EQS_P13?.active || window.EQS_P13D?.active) { console.warn('[EQS P13-E] Remove P13-C/P13-D and refresh before loading P13-E. No changes made.'); return; } const ROOT = '.griditems.gridlist-grid'; const CARD = '.tileparent.product.eqs-p542'; const STYLE_ID = 'eqs-p13e-css'; // Future, independently verified data only. No inferred or default discounts. // Example: SKU: { list: 2163.89, uom: 'EA', verified: true } const VERIFIED_LIST = Object.freeze({}); // Future editorial enhancements can be supplied here, after source review. // Example: SKU: ['Verified feature 1', 'Verified feature 2', 'Verified feature 3'] const VERIFIED_FEATURES = Object.freeze({}); const saved = new Map(); let scans = 0, queued = false; const css = document.createElement('style'); css.id = STYLE_ID; css.textContent = ` ${ROOT}:has(> ${CARD}){display:flex!important;flex-wrap:wrap!important;align-items:stretch!important;width:100%!important;gap:12px 0!important} ${ROOT}>${CARD}{box-sizing:border-box!important;flex:0 0 25%!important;width:25%!important;max-width:25%!important;min-width:0!important;float:none!important;padding:0 6px!important;border:1px solid #cbd8d4!important;border-radius:14px!important;box-shadow:none!important;outline:none!important;background:#fff!important;min-height:0!important;overflow:hidden!important} ${CARD}>.tile{display:flex!important;flex-direction:column!important;height:100%!important;min-height:0!important;padding:12px 16px 14px!important;border:0!important;box-shadow:none!important;outline:none!important;background:transparent!important} ${CARD}>.tile>.footer,${CARD} .footer-wrapper,${CARD} .footer-wrapper-description{border:0!important;box-shadow:none!important;outline:none!important;background:transparent!important} ${CARD} .product-tile-image,${CARD} .product-tile-image .text-center,${CARD} .imgthumbnail{height:185px!important;min-height:185px!important;display:flex!important;align-items:center!important;justify-content:center!important;border:0!important;box-shadow:none!important} ${CARD} .product-tile-image img{height:180px!important;width:100%!important;max-width:100%!important;object-fit:contain!important} ${CARD} .eqs-p542-brandrow{height:37px!important;min-height:37px!important;margin:2px 0 4px!important;gap:7px!important} ${CARD} .brand-label{width:48%!important;max-width:48%!important} ${CARD} .brand-label img{width:100%!important;max-width:145px!important;max-height:34px!important;object-fit:contain!important;object-position:left center!important} ${CARD} .eqs-p542-delivery{font:700 11px/14px Arial,sans-serif!important;white-space:nowrap!important} ${CARD} .eqs-p542-delivery svg{width:32px!important;height:22px!important} ${CARD} .product-name{height:44px!important;max-height:44px!important;margin:2px 0 4px!important;-webkit-line-clamp:2!important} ${CARD} .product-name,${CARD} .product-name a{font:700 15px/21px Arial,sans-serif!important;color:#111!important} ${CARD} .eqs-p542-description{display:none!important} ${CARD} .eqs-p13e-features{display:flex;flex-direction:column;gap:3px;margin:5px 0 12px;min-height:0} ${CARD} .eqs-p13e-feature{display:flex;align-items:flex-start;gap:9px;font:13px/18px Arial,sans-serif;color:#111} ${CARD} .eqs-p13e-feature:before{content:'●';font-size:11px;color:#00843d;line-height:18px;flex:none} ${CARD} .eqs-p13e-meta{font:12px/18px Arial,sans-serif;color:#111;display:flex;flex-direction:column;gap:1px;margin:0 0 12px} ${CARD} .eqs-p13e-meta b{font-weight:700} ${CARD} .eqs-p13e-category{color:#00843d} ${CARD} .eqs-p13e-hidden{display:none!important} ${CARD} .eqs-p13e-pricebar{display:flex;align-items:center;gap:9px;margin-top:auto;margin-bottom:10px;min-height:55px;border:0!important;box-shadow:none!important} ${CARD} .eqs-p13e-pricestack{display:flex;flex-direction:column;min-width:0;flex:1 1 auto} ${CARD} .footer-wrapper-price{margin:0!important;padding:0!important;min-height:0!important;display:flex!important;align-items:flex-end!important;min-width:0!important} ${CARD} .price-label{font:800 24px/28px Arial,sans-serif!important;color:#00843d!important;white-space:nowrap!important} ${CARD} .uom,${CARD} .uomvalue{font:12px Arial,sans-serif!important;color:#111!important;white-space:nowrap!important} ${CARD} .eqs-p13e-list{font:12px/17px Arial,sans-serif;color:#333;margin-bottom:4px;white-space:nowrap} ${CARD} .eqs-p13e-list s{text-decoration-thickness:1px} ${CARD} .eqs-p13e-savings{border-left:1px solid #98a2a3;padding-left:10px;text-align:right;min-width:95px;flex:0 0 auto;color:#64748b} ${CARD} .eqs-p13e-savings .label{font:600 10px/14px Arial,sans-serif;white-space:nowrap} ${CARD} .eqs-p13e-savings .amount{font:700 17px/22px Arial,sans-serif;white-space:nowrap} ${CARD} .buttons.group{height:44px!important;min-height:44px!important;gap:7px!important;margin:0!important;border:0!important;box-shadow:none!important} ${CARD} .inputquantity{height:44px!important;min-width:50px!important;width:50px!important;flex:0 0 50px!important} ${CARD} .live-inventory-v2-add-to-cart-wrapper,${CARD} .btn-add-to-cart{height:44px!important;min-height:44px!important} ${CARD} .btn-add-to-cart{background:#008000!important;font:700 14px Arial,sans-serif!important} @media(max-width:1099px){${ROOT}>${CARD}{flex-basis:50%!important;width:50%!important;max-width:50%!important}} @media(max-width:600px){${ROOT}>${CARD}{flex-basis:100%!important;width:100%!important;max-width:100%!important}} `; document.head.append(css); const skuOf = card => (card.querySelector('.product-sku')?.textContent || '') .match(/(?:ITEM\s*CODE|SKU)\s*:?\s*([A-Z0-9&-]+)/i)?.[1]?.toUpperCase() || ''; const priceOf = card => { const t = card.querySelector('.footer-wrapper-price .price-label')?.textContent || ''; const m = t.replace(/,/g, '').match(/\$\s*(\d+(?:\.\d{1,2})?)/); return m ? Number(m[1]) : null; }; const featuresOf = (card, sku) => { if (Array.isArray(VERIFIED_FEATURES[sku])) return VERIFIED_FEATURES[sku].slice(0, 3); const original = [...card.querySelectorAll('.product-points li,.product-short-description li,.short-description li')] .map(n => n.textContent.trim().replace(/\s+/g, ' ')).filter(Boolean); if (original.length) return [...new Set(original)].slice(0, 3); const description = card.querySelector('.eqs-p542-description')?.textContent.trim() || ''; return [...new Set(description.split(/\.(?:\s+|$)/).map(s => s.trim()).filter(Boolean))].slice(0, 3); }; function apply(card) { if (saved.has(card)) return; const desc = card.querySelector('.eqs-p542-description'); const price = card.querySelector('.footer-wrapper-price'); const skuNode = card.querySelector('.product-sku'); if (!desc || !price || !skuNode || !price.parentNode) return; const sku = skuOf(card); const category = card.querySelector('.product-category'); const collection = card.querySelector('.eqs-p3-collection'); const featureBox = document.createElement('div'); featureBox.className = 'eqs-p13e-features'; const features = featuresOf(card, sku); for (const t of features) { const line = document.createElement('div'); line.className = 'eqs-p13e-feature'; line.textContent = t; featureBox.append(line); } if (!features.length) featureBox.style.display = 'none'; desc.insertAdjacentElement('afterend', featureBox); const meta = document.createElement('div'); meta.className = 'eqs-p13e-meta'; function add(label, value, cls = '') { if (!value) return; const row = document.createElement('div'), b = document.createElement('b'), span = document.createElement('span'); b.textContent = label + ': '; span.textContent = value; if (cls) span.className = cls; row.append(b, span); meta.append(row); } add('Category', category?.textContent.trim().replace(/^Category\s*:?\s*/i, '').replace(/\s+/g, ' '), 'eqs-p13e-category'); add('Collection', collection?.textContent.replace(/^Collection\s*:\s*/i, '').trim()); add('Item Code', sku); featureBox.insertAdjacentElement('afterend', meta); const hidden = [skuNode, category, collection].filter(Boolean); hidden.forEach(n => n.classList.add('eqs-p13e-hidden')); const parent = price.parentNode, next = price.nextSibling; const bar = document.createElement('div'); bar.className = 'eqs-p13e-pricebar'; const stack = document.createElement('div'); stack.className = 'eqs-p13e-pricestack'; parent.insertBefore(bar, price); bar.append(stack); stack.append(price); const record = VERIFIED_LIST[sku], native = priceOf(card); const uom = (card.querySelector('.uomvalue,.uom')?.textContent || '').trim().replace(/^\//, '').toUpperCase(); if (record?.verified === true && Number.isFinite(record.list) && record.list > native && native > 0 && record.uom === uom) { const actual = (1 - native / record.list) * 100; if (actual >= 36) { const list = document.createElement('div'); list.className = 'eqs-p13e-list'; list.append(document.createTextNode('List Price: ')); const s = document.createElement('s'); s.textContent = record.list.toLocaleString('en-US', {style:'currency',currency:'USD'}); list.append(s); stack.prepend(list); const savings = document.createElement('div'); savings.className = 'eqs-p13e-savings'; const label = document.createElement('div'); label.className = 'label'; label.textContent = 'Your Emerald Savings'; const amount = document.createElement('div'); amount.className = 'amount'; amount.textContent = Math.round(actual) + '% off list'; savings.append(label, amount); bar.append(savings); } } saved.set(card, {featureBox, meta, hidden, price, parent, next, bar, featureCount:features.length, sku}); } function scan() { scans++; for (const card of document.querySelectorAll(CARD)) apply(card); for (const card of saved.keys()) if (!card.isConnected) saved.delete(card); } const observer = new MutationObserver(mutations => { if (queued || !mutations.some(m => [...m.addedNodes].some(n => n.nodeType === 1 && (n.matches?.('.tileparent.product') || n.querySelector?.('.tileparent.product'))))) return; queued = true; requestAnimationFrame(() => { queued = false; scan(); }); }); observer.observe(document.body, {childList:true,subtree:true}); scan(); window.EQS_P13E = { active:true, status:() => ({nativeCards:document.querySelectorAll('.tileparent.product').length, p9StyledCards:document.querySelectorAll(CARD).length,p13Applied:saved.size, threeFeatureCards:[...saved.values()].filter(x => x.featureCount === 3).length, fewerThanThree:[...saved.values()].filter(x => x.featureCount < 3).map(x => x.sku), verifiedSavingsClaims:document.querySelectorAll('.eqs-p13e-savings').length, nativeCartButtons:document.querySelectorAll('.tileparent.product .btn-add-to-cart').length,scans}), rescan:scan, remove:() => { observer.disconnect(); for (const x of saved.values()) { x.featureBox.remove(); x.meta.remove(); x.hidden.forEach(n => n.classList.remove('eqs-p13e-hidden')); if (x.next?.parentNode === x.parent) x.parent.insertBefore(x.price, x.next); else x.parent.append(x.price); x.bar.remove(); } saved.clear(); css.remove(); delete window.EQS_P13E; console.info('[EQS P13-E] Removed. P9 remains unchanged.'); } }; console.info('[EQS P13-E] READY', window.EQS_P13E.status()); })();