/* EMERALD QUICK SHIP - WORKSTATIONS CARDS V1 November 18, 2026 One self-contained script for the Workstations category (EvoX category 1366569). Same card design as Desks and Seating: two-line titles that name the finish or material, three one-line benefit bullets, Category / Collection / Item Code, list price with Emerald Savings when the item is sold each and the native price is at least 36% below verified list, 140px image area. Runs at both addresses of the category (/category/1366569-... and /workstations--17) by checking the page's category id. Native prices, quantity box and Add to Cart are never changed. Cards without a price or Add to Cart button (signed-out visitors) stay native. */ (() => { 'use strict'; if (!document.body || !document.body.classList.contains('ex-categoryid-1366569')) return; if (window.EQS_WS?.active) return; const VERSION = 'EQS_WORKSTATIONS_V1B_2026_11_18'; // ---- Items removed from the Workstations page, plus the empty EvoX placeholder tile (hidden for every visitor) ---- const HIDE_SKUS = ['GLBCMQS555']; if (!document.getElementById('eqs-tables-hide')) { const hs = document.createElement('style'); hs.id = 'eqs-tables-hide'; hs.textContent = HIDE_SKUS.map(k => `.griditems .tileparent.product[data-sku="${k}" i]`).concat('.griditems .tileparent.tileparent_placeholder').join(',') + '{display:none!important}'; (document.head || document.documentElement).appendChild(hs); } const CARD = '.tileparent.product'; const MIN_DISCOUNT = 36; // Items sold as a set or carton: the native price covers this many chairs. const PER_SET = {}; // sku: [title, bullet1, bullet2, bullet3, collection, listPrice, imgScale, imgX, imgY] const DATA = { "GLBCMQS508":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "42\" panels keep teams in touch", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 17022, 1.526, 1.5, 7.6], "GLBCMQS508W":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 20694, 1.504, 3.0, 3.0], "GLBCMQS510":["6-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 29229, 1.411, 0.7, -0.0], "GLBCMQS511":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 17254, 1.537, 0.8, 3.8], "GLBCMQS512":["6-Person 6' x 6' Workstation, Custom Fabric & Finish", "66\" panels give full privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 31354, 1.493, 0.7, 3.7], "GLBCMQS517":["4-Person 6' x 8' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 25750, 1.392, 2.1, 0.7], "GLBCMQS538":["4-Person 8' x 6' Workstation, Custom Fabric & Finish", "42\" panels keep teams in touch", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 18144, 1.537, 0.8, 4.6], "GLBCMQS539":["4-Person 8' x 6' Workstation, Custom Fabric & Finish", "66\" panels give full privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 30412, 1.571, 5.5, 0.8], "GLBCMQS540":["6-Person 3.5' x 2' Station, Custom Fabric & Finish", "42\" panels keep teams in touch", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 11685, 1.517, -3.0, 1.5], "GLBCMQS541":["4-Person 6' x 6' L-Shaped Cubicles, Custom Finishes", "42\" panels keep teams in touch", "Four L-shaped cubicle layout", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 18812, 1.571, 0.8, 0.8], "GLBCMQS542":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "42\" panels keep teams in touch", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 17875, 1.517, 0.8, 3.0], "GLBCMQS543":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 21282, 1.571, 0.8, 0.8], "GLBCMQS544":["4-Person 6' x 8' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 21226, 1.553, -3.1, 1.6], "GLBCMQS545":["4-Person 8' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 24208, 1.5, 4.5, -0.8], "GLBCMQS546":["6-Person 8' x 8' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 27844, 1.553, 2.3, 1.6], "GLBCMQS547":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "66\" panels give full privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 24800, 1.6, 7.2, 4.8], "GLBCMQS548":["6-Person 6' x 8' Workstation, Custom Fabric & Finish", "66\" panels give full privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 27114, 1.59, -0.8, -0.0], "GLBCMQS549":["4-Person 8' x 8' Workstation, Custom Fabric & Finish", "66\" panels give full privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 29918, 1.535, 2.3, 3.8], "GLBCMQS550":["6-Person 6' x 2' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 17836, 1.373, 2.1, 1.4], "GLBCMQS551":["6-Person 6' x 2' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 23290, 1.346, 1.3, 0.7], "GLBCMQS552":["6-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 28843, 1.272, -1.9, 1.3], "GLBCMQS553":["6-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 34751, 1.364, -1.4, -2.0], "GLBCMQS556":["4-Person 6' x 6' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 20196, 1.504, -0.0, 2.3], "GLBCMQS567":["4-Person 4' x 2' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 9212, 1.571, -0.0, 2.4], "GLBCMQS567W":["6-Person 4' x 2' Workstation, Custom Fabric & Finish", "54\" panels add seated privacy", "Reconfigures as teams grow", "35 fabrics, 4 laminate finishes", "Compile Quick Ship", 15225, 1.517, 0.8, 1.5], "OTGLAYOUTSL5ADC":["4-Person Bench Desks, American Dark Cherry", "Four 48\" x 30\" work surfaces", "Acrylic panels define each desk", "Locking mobile files included", "OTG Layouts", 4564, 1.361, -0.0, 2.7], "OTGLAYOUTSL5AEL":["4-Person Bench Desks, American Espresso", "Four 48\" x 30\" work surfaces", "Acrylic panels define each desk", "Locking mobile files included", "OTG Layouts", 4564, 1.361, -0.0, 2.7], "OTGLAYOUTSL5AGL":["4-Person Bench Desks, Artisan Grey Laminate", "Four 48\" x 30\" work surfaces", "Acrylic panels define each desk", "Locking mobile files included", "OTG Layouts", 4564, 1.031, -2.6, -0.5], "OTGLAYOUTSL5AML":["4-Person Bench Desks, American Mahogany", "Four 48\" x 30\" work surfaces", "Acrylic panels define each desk", "Locking mobile files included", "OTG Layouts", 4564, 1.361, -0.0, 2.7], "OTGLAYOUTSL5AWL":["4-Person Bench Desks, Autumn Walnut Laminate", "Four 48\" x 30\" work surfaces", "Acrylic panels define each desk", "Locking mobile files included", "OTG Layouts", 4564, 1.361, -0.0, 2.7], "OTGLAYOUTSL6ADC":["2-Person L-Desks, American Dark Cherry Laminate", "Two L-desks, 96\" x 96\" overall", "Panels give each desk privacy", "Four locking pedestal files", "OTG Layouts", 5336, 1.307, 0.7, 1.3], "OTGLAYOUTSL6AEL":["2-Person L-Desks, American Espresso Laminate", "Two L-desks, 96\" x 96\" overall", "Panels give each desk privacy", "Four locking pedestal files", "OTG Layouts", 5336, 1.307, 0.7, 1.3], "OTGLAYOUTSL6AGL":["2-Person L-Desks, Artisan Grey Laminate", "Two L-desks, 96\" x 96\" overall", "Panels give each desk privacy", "Four locking pedestal files", "OTG Layouts", 5336, 1.32, 0.7, 0.7], "OTGLAYOUTSL6AML":["2-Person L-Desks, American Mahogany Laminate", "Two L-desks, 96\" x 96\" overall", "Panels give each desk privacy", "Four locking pedestal files", "OTG Layouts", 5336, 1.307, 0.7, 1.3], "OTGLAYOUTSL6AWL":["2-Person L-Desks, Autumn Walnut Laminate", "Two L-desks, 96\" x 96\" overall", "Panels give each desk privacy", "Four locking pedestal files", "OTG Layouts", 5336, 1.32, 0.7, 0.7] }; const DELIVERY = [ [/^GLBCMQS/, '10\u201314 Days'], [/^(JMLOTG|OTG)/, '5\u20137 Day Delivery'] ]; const CATEGORY_LABEL = { 'Executive & Conference Seating': 'Executive & Conference' }; const TRUCK = ''; const CART = ''; // ---- Retire the older P11 adapter if it is still loaded ---- // ---- Styles (scoped to styled Workstations cards) ---- const S = 'html body .griditems.gridlist-grid > .tileparent.product.eqs-ws'; const style = document.createElement('style'); style.id = 'eqs-tables-v1-style'; style.textContent = ` ${S}{box-sizing:border-box!important;float:left!important;width:calc(25% - 12px)!important;height:455px!important;min-height:455px!important;margin:0 6px 14px!important;padding:0 6px!important;background:#fff!important;border:.667px solid rgb(203,216,212)!important;border-radius:14px!important;box-shadow:none!important;overflow:hidden!important} @media (max-width:1199px){${S}{width:calc(33.333% - 12px)!important}} @media (max-width:991px){${S}{width:calc(50% - 12px)!important}} @media (max-width:767px){${S}{width:calc(100% - 12px)!important}} ${S} > .tile{display:flex!important;flex-direction:column!important;height:454px!important;min-height:0!important;padding:0 14px 8px!important;margin:0!important;border:0!important;background:transparent!important} ${S} .badges-wrapper,${S} .product-list-actions,${S} .addtoquicklist-wrapper,${S} .product-compare-action,${S} .emerald-closeout-deal-badge,${S} .live-inventory-v2-shipping,${S} .live-inventory-v2-wrapper,${S} .product-name,${S} .product-sku,${S} .product-category,${S} .indicators-grid,${S} .product-points,${S} .multiple-uom-label,${S} .eqs-p542-description,${S} .eqs-p3-collection,${S} .product-short-description,${S} .short-description{display:none!important} ${S} .footer-wrapper-price{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;clip:rect(0 0 0 0)!important;margin:0!important;padding:0!important} ${S} .product-tile-image{position:relative!important;display:flex!important;justify-content:center!important;align-items:center!important;height:140px!important;min-height:140px!important;max-height:140px!important;overflow:hidden!important;margin:0!important;padding:0!important;flex:0 0 140px!important} ${S} .product-tile-image .text-center,${S} .product-tile-image .imgthumbnail{position:static!important;display:flex!important;justify-content:center!important;align-items:center!important;height:140px!important;width:100%!important;margin:0!important;padding:0!important;overflow:visible!important} ${S} .product-tile-image .thumb-align{display:none!important} ${S} .product-tile-image img{width:200px!important;height:200px!important;min-height:200px!important;max-width:none!important;max-height:none!important;object-fit:contain!important;transform-origin:center center!important;flex:0 0 200px!important;position:absolute!important;top:50%!important;left:50%!important;margin:-100px 0 0 -100px!important} ${S} .ebi-textile-badge{display:none!important} ${S} .footer{display:flex!important;flex-direction:column!important;flex:1 1 auto!important;height:auto!important;min-height:0!important;margin:0!important;padding:0!important} ${S} .footer-wrapper{display:flex!important;flex-direction:column!important;height:auto!important;min-height:0!important;margin:0!important;padding:0!important;position:relative!important} ${S} .footer-wrapper-description{display:flex!important;flex-direction:column!important;height:auto!important;min-height:0!important;margin:0!important;padding:0!important} ${S} .eqs-ws-brandrow{display:flex!important;justify-content:space-between!important;align-items:center!important;gap:7px!important;height:37px!important;min-height:37px!important;margin:12px 0 1px!important;padding:0!important} ${S} .eqs-ws-brandrow .brand-label{display:flex!important;align-items:center!important;flex:0 1 auto!important;min-width:0!important;max-width:96px!important;margin:0!important;padding:0!important} ${S} .eqs-ws-brandrow .brand-label a{display:flex!important;align-items:center!important;line-height:0!important;min-width:0!important;max-width:100%!important} ${S} .eqs-ws-brandrow .brand-label img{width:auto!important;height:auto!important;max-width:100%!important;max-height:20px!important;object-fit:contain!important;object-position:left center!important;margin:0!important} ${S} .eqs-ws-delivery{display:inline-flex!important;align-items:center!important;justify-content:flex-end!important;gap:3px!important;flex:0 0 auto!important;white-space:nowrap!important;color:rgb(0,132,61)!important;font:700 11px/14px Arial,sans-serif!important} ${S} .eqs-ws-delivery svg{width:32px!important;height:22px!important;flex:0 0 32px!important;fill:none!important;stroke:currentColor!important;stroke-width:2!important;stroke-linecap:round!important;stroke-linejoin:round!important} ${S} .eqs-ws-title{display:block!important;height:38px!important;min-height:38px!important;max-height:38px!important;overflow:hidden!important;margin:0 0 4px!important;padding:0!important;color:rgb(2,2,2)!important;font:700 14px/19px Arial,sans-serif!important;text-decoration:none!important} ${S} .eqs-ws-title:hover{text-decoration:underline!important} ${S} .eqs-ws-features{display:flex!important;flex-direction:column!important;height:48px!important;min-height:48px!important;margin:0 0 4px!important;padding:0!important} ${S} .eqs-ws-feature{display:flex!important;align-items:flex-start!important;gap:5px!important;height:16px!important;overflow:hidden!important;white-space:nowrap!important;color:rgb(17,17,17)!important;font:12px/16px Arial,sans-serif!important} ${S} .eqs-ws-dot{flex:0 0 10px!important;width:10px!important;color:rgb(67,131,70)!important} ${S} .eqs-ws-meta{display:flex!important;flex-direction:column!important;height:51px!important;min-height:51px!important;margin:0 0 2px!important;padding:0!important;color:rgb(100,116,139)!important;font:11px/17px Arial,sans-serif!important} ${S} .eqs-ws-meta > div{height:17px!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important} ${S} .eqs-ws-meta b{font-weight:600!important;color:rgb(71,85,105)!important} ${S} .eqs-ws-meta .eqs-ws-cat{font-weight:500!important;color:rgb(67,138,98)!important} ${S} .eqs-ws-meta .eqs-ws-code{letter-spacing:-.2px!important} ${S} .eqs-ws-pricebar{display:flex!important;justify-content:space-between!important;align-items:flex-end!important;gap:5px!important;height:55px!important;min-height:55px!important;margin:0 0 10px!important;padding:0!important;box-sizing:border-box!important} ${S} .eqs-ws-list{height:14px!important;margin:0 0 1px!important;color:rgb(71,84,103)!important;font:11px/14px Arial,sans-serif!important;white-space:nowrap!important} ${S} .eqs-ws-list s{color:rgb(102,112,133)!important} ${S} .eqs-ws-price{display:flex!important;align-items:flex-start!important;height:31px!important;color:rgb(67,133,74)!important;font:800 26px/31px Arial,sans-serif!important;letter-spacing:-.5px!important;white-space:nowrap!important} ${S} .eqs-ws-cents{display:block!important;margin:1px 0 0 1px!important;font:800 12px/12px Arial,sans-serif!important;letter-spacing:0!important} ${S} .eqs-ws-savings{margin:0 0 2px!important;text-align:right!important;color:rgb(100,116,139)!important;white-space:nowrap!important} ${S} .eqs-ws-savings-label{font:600 9px/12px Arial,sans-serif!important} ${S} .eqs-ws-savings-pct{font:500 13px/17px Arial,sans-serif!important} ${S} .buttons.group{display:flex!important;flex-direction:row!important;align-items:flex-start!important;gap:7px!important;height:44px!important;min-height:44px!important;margin:0!important;padding:0!important;text-align:left!important} ${S} .inputquantity{width:50px!important;min-width:50px!important;flex:0 0 50px!important;height:44px!important;padding:5px!important;border:.667px solid rgb(216,222,230)!important;border-radius:5px!important;background:#fff!important;text-align:center!important;font:16px Arial,sans-serif!important;margin:0!important} ${S} .live-inventory-v2-add-to-cart-wrapper{display:flex!important;flex:1 1 auto!important;width:auto!important;min-width:0!important;height:44px!important;margin:0!important} ${S} .btn-add-to-cart{display:flex!important;align-items:center!important;justify-content:center!important;gap:5px!important;width:100%!important;height:44px!important;min-height:44px!important;margin:0!important;padding:0 6px!important;background:rgb(0,128,0)!important;color:#fff!important;border:0!important;border-radius:5px!important;font:700 14px Arial,sans-serif!important;white-space:nowrap!important} ${S} .eqs-ws-carticon{display:inline-flex!important;width:20px!important;height:20px!important;flex:0 0 20px!important} ${S} .eqs-ws-carticon svg{width:20px!important;height:20px!important;fill:none!important;stroke:currentColor!important;stroke-width:2!important} ${S} .eqs-ws-per{align-self:flex-end!important;margin:0 0 4px 7px!important;color:rgb(71,84,103)!important;font:600 12px/14px Arial,sans-serif!important;letter-spacing:0!important;white-space:nowrap!important} ${S} .eqs-ws-brandrow .brand-label:has(img[alt*="National Public" i]){max-width:112px!important;flex:0 0 112px!important} ${S} .eqs-ws-brandrow .brand-label:has(img[alt*="National Public" i]) a{width:100%!important} ${S} .eqs-ws-brandrow .brand-label img[alt*="National Public" i]{width:112px!important;height:auto!important;max-height:none!important;max-width:none!important} ${S} .eqs-ws-brandrow .brand-label:has(img[alt*="Global" i]),${S} .eqs-ws-brandrow .brand-label:has(img[src*="Global" i]){max-width:none!important;flex:0 0 auto!important;overflow:visible!important} ${S} .eqs-ws-brandrow .brand-label:has(img[alt*="Global" i]) a,${S} .eqs-ws-brandrow .brand-label:has(img[src*="Global" i]) a{overflow:visible!important} ${S} .eqs-ws-brandrow .brand-label img[alt*="Global" i],${S} .eqs-ws-brandrow .brand-label img[src*="Global" i]{max-height:46px!important;height:46px!important;width:auto!important;max-width:none!important;margin:-8px 0 -1px -8px!important;position:relative!important;z-index:1!important} `; document.head.append(style); // ---- Helpers ---- const money = n => '$' + Number(n).toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }); const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; }; const skuOf = card => (card.dataset.sku || '').trim().toUpperCase(); const deliveryFor = sku => (DELIVERY.find(([re]) => re.test(sku)) || [null, ''])[1]; function nativePrice(card) { const label = card.querySelector('.footer-wrapper-price .price-label'); if (!label) return NaN; const raw = label.getAttribute('data-value'); let v = raw != null && raw.trim() !== '' ? Number(raw) : NaN; if (!Number.isFinite(v)) { const m = (label.textContent || '').replace(/,/g, '').match(/\$\s*(\d+(?:\.\d{1,2})?)/); v = m ? Number(m[1]) : NaN; } return v; } const state = { runs: 0, errors: [], unknown: new Set(), skipped: new Set() }; function build(card, sku, d) { const q = s => card.querySelector(s); const desc = q('.footer-wrapper-description'); const fw = q('.footer-wrapper'); const nativeP = q('.footer-wrapper-price'); const button = q('.btn-add-to-cart'); const img = q('.product-tile-image img'); if (!desc || !fw || !nativeP || !button) return false; // Clean up P11 leftovers card.classList.remove('eqs-p11'); card.querySelectorAll('.eqs-p542-description,.eqs-p3-collection').forEach(n => n.remove()); // Brand row let row = q('.eqs-ws-brandrow') || q('.eqs-p542-brandrow'); if (!row) row = el('div'); row.className = 'eqs-ws-brandrow'; row.querySelector('.eqs-p542-delivery')?.remove(); const logo = q('.brand-label'); if (logo && logo.parentElement !== row) row.prepend(logo); let del = row.querySelector('.eqs-ws-delivery'); if (!del) { del = el('div', 'eqs-ws-delivery'); del.innerHTML = TRUCK + ''; row.append(del); } del.querySelector('span').textContent = deliveryFor(sku); if (row.parentElement !== desc || desc.firstChild !== row) desc.prepend(row); // Title (links to the product page) const href = q('.product-name a')?.getAttribute('href') || q('.product-tile-image')?.getAttribute('href') || '#'; let title = q('.eqs-ws-title'); if (!title) { title = el('a', 'eqs-ws-title'); row.after(title); } title.setAttribute('href', href); title.textContent = d[0]; title.title = d[0]; // Bullets let feats = q('.eqs-ws-features'); if (!feats) { feats = el('div', 'eqs-ws-features'); title.after(feats); } feats.replaceChildren(...[d[1], d[2], d[3]].map(t => { const f = el('div', 'eqs-ws-feature'); f.append(el('span', 'eqs-ws-dot', '\u2022'), el('span', 'eqs-ws-copy', t)); return f; })); // Category / Collection / Item Code const rawCat = (q('.product-category a')?.textContent || '').replace(/\s+/g, ' ').trim(); const cat = CATEGORY_LABEL[rawCat] || rawCat || 'Workstations'; let meta = q('.eqs-ws-meta'); if (!meta) { meta = el('div', 'eqs-ws-meta'); feats.after(meta); } const r1 = el('div'); r1.append(el('b', '', 'Category: '), el('span', 'eqs-ws-cat', cat)); const r2 = el('div'); r2.append(el('b', '', 'Collection: '), el('span', '', d[4])); const r3 = el('div'); r3.append(el('b', '', 'Item Code: '), el('span', 'eqs-ws-code', sku)); meta.replaceChildren(r1, r2, r3); // Price bar let bar = q('.eqs-ws-pricebar'); if (!bar) { bar = el('div', 'eqs-ws-pricebar'); const left = el('div', 'eqs-ws-left'); left.append(el('div', 'eqs-ws-list'), el('div', 'eqs-ws-price')); const sav = el('div', 'eqs-ws-savings'); sav.append(el('div', 'eqs-ws-savings-label', 'Emerald Savings'), el('div', 'eqs-ws-savings-pct')); bar.append(left, sav); fw.insertBefore(bar, nativeP); } // Cart icon if (!button.querySelector('.eqs-ws-carticon')) { button.querySelector('.eqs-p542-carticon')?.remove(); const icon = el('span', 'eqs-ws-carticon'); icon.innerHTML = CART; button.prepend(icon); } // Image sizing if (img) { const t = `translate(${d[7]}px,${d[8]}px) scale(${d[6]})`; if (img.style.getPropertyValue('transform') !== t) img.style.setProperty('transform', t, 'important'); } card.dataset.eqsSeat = sku; card.classList.add('eqs-ws'); return true; } function updatePrice(card, sku, d) { const bar = card.querySelector('.eqs-ws-pricebar'); if (!bar) return; const sell = nativePrice(card); const list = Number(d[5]); const pack = (card.dataset.packUom || '').trim().toUpperCase(); const uom = (card.querySelector('.footer-wrapper-price .uomvalue')?.textContent || '').replace(/[\s/]/g, '').toUpperCase(); const disc = list > 0 && sell > 0 ? (1 - sell / list) * 100 : NaN; const ok = Number.isFinite(disc) && disc >= MIN_DISCOUNT && pack === 'EA' && (!uom || uom === 'EA'); const listEl = bar.querySelector('.eqs-ws-list'); const priceEl = bar.querySelector('.eqs-ws-price'); const sav = bar.querySelector('.eqs-ws-savings'); const perSet = PER_SET[sku] || 0; const key = sell + '|' + (ok ? 1 : 0) + '|' + perSet; if (bar.dataset.key === key) return; bar.dataset.key = key; if (sell > 0) { const [whole, cents] = money(sell).split('.'); priceEl.replaceChildren(document.createTextNode(whole + '.'), el('span', 'eqs-ws-cents', cents)); if (perSet) priceEl.append(el('span', 'eqs-ws-per', perSet === 'set' ? 'per set' : 'per set of ' + perSet)); } else { priceEl.replaceChildren(); } if (ok) { listEl.replaceChildren(document.createTextNode('List Price: '), el('s', '', money(list))); listEl.style.visibility = ''; sav.querySelector('.eqs-ws-savings-pct').textContent = Math.round(disc) + '% off list'; sav.style.visibility = ''; } else { listEl.replaceChildren(); listEl.style.visibility = 'hidden'; sav.style.visibility = 'hidden'; } sav.style.display = perSet && !ok ? 'none' : ''; } function run() { state.runs++; observer.disconnect(); try { for (const card of document.querySelectorAll('.griditems ' + CARD)) { const sku = skuOf(card); const d = DATA[sku]; if (!d) { state.unknown.add(sku); continue; } try { if (card.dataset.eqsSeat !== sku || !card.querySelector('.eqs-ws-title')) { if (!build(card, sku, d)) { state.skipped.add(sku); continue; } } else { const img = card.querySelector('.product-tile-image img'); const t = `translate(${d[7]}px,${d[8]}px) scale(${d[6]})`; if (img && img.style.getPropertyValue('transform') !== t) img.style.setProperty('transform', t, 'important'); } updatePrice(card, sku, d); } catch (e) { if (state.errors.length < 20) state.errors.push(sku + ': ' + e.message); } } } finally { observer.observe(document.body, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['data-value', 'src'] }); } } // Debounced (timer-based, so it also works in background tabs) let timer = 0, first = 0, burst = []; function schedule() { const now = Date.now(); if (!first) first = now; clearTimeout(timer); const wait = now - first > 600 ? 0 : 120; timer = setTimeout(() => { first = 0; burst = burst.filter(t => now - t < 10000); if (burst.length >= 30) return; // safety brake burst.push(now); run(); }, wait); } const observer = new MutationObserver(muts => { for (const m of muts) { const t = m.target.nodeType === 1 ? m.target : m.target.parentElement; if (!t) continue; if (t.closest?.('.eqs-ws-title,.eqs-ws-features,.eqs-ws-meta,.eqs-ws-pricebar,.eqs-ws-brandrow')) continue; if (t.closest?.('.griditems') || [...(m.addedNodes || [])].some(n => n.nodeType === 1 && (n.matches?.(CARD) || n.querySelector?.(CARD)))) { schedule(); return; } } }); run(); const boot = setInterval(() => { if (document.querySelector('.griditems ' + CARD)) run(); }, 400); setTimeout(() => clearInterval(boot), 8000); window.EQS_WS = { active: true, version: VERSION, rescan: run, status: () => { const cards = [...document.querySelectorAll('.griditems ' + CARD)]; return { version: VERSION, nativeCards: cards.length, styledCards: cards.filter(c => c.classList.contains('eqs-ws')).length, withSavings: cards.filter(c => c.querySelector('.eqs-ws-savings') && c.querySelector('.eqs-ws-savings').style.visibility !== 'hidden').length, cartButtons: cards.filter(c => c.querySelector('.btn-add-to-cart')).length, unknownSkus: [...state.unknown], skipped: [...state.skipped], errors: state.errors.slice(), runs: state.runs }; }, remove: () => { observer.disconnect(); clearInterval(boot); clearTimeout(timer); style.remove(); document.querySelectorAll('.eqs-ws').forEach(c => c.classList.remove('eqs-ws')); delete window.EQS_WS; console.info('[EQS SEATING] Removed. Refresh to restore the original cards.'); } }; console.info('[EQS SEATING]', VERSION, 'installed'); })();