/*
EMERALD QUICK SHIP - MONITOR ARMS & KEYBOARD TRAYS CARDS V1
November 19, 2026
One self-contained script for the Monitor Arms & Keyboard Trays
category (EvoX category 1366572). 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 below the provided list (36% rule for OfficeSource and N9N), 140px image area.
Runs at both addresses of the category (/category/1366572-... and
/monitor-arms-and-desk-accessories) 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-1366572')) return;
if (window.EQS_MA?.active) return;
const VERSION = 'EQS_MONITORARMS_V1_2026_11_19';
// ---- Items removed from the Boards page, plus the empty EvoX placeholder tile (hidden for every visitor) ----
const HIDE_SKUS = [];
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, BOARD_MIN_DISCOUNT = 1;
// 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 = {
"COEOSAC4008CR":["Single Monitor Arm with USB-A & USB-C, Charcoal", "Built-in USB-A and USB-C ports", "Holds monitors up to 19.5 lb", "Clamp or grommet mount", "OfficeSource", 207.0, 0.66, 0.3, 0.3],
"COEOSAC4009CR":["Dual Monitor Arm with USB-A & USB-C, Charcoal", "Two arms, two screens", "Built-in USB-A and USB-C ports", "Clamp or grommet mount", "OfficeSource", 350.0, 0.66, 0.3, 0.3],
"COEOSAC4010BK":["Triple Monitor Arm with USB-A & USB-C, Black", "Three screens, one clean desk", "Built-in USB-A and USB-C ports", "Clamp or grommet mount", "OfficeSource", 1414.0, 0.66, 0.3, 0.3],
"COEOSAC4010SI":["Triple Monitor Arm with USB-A & USB-C, Silver", "Three screens, one clean desk", "Built-in USB-A and USB-C ports", "Clamp or grommet mount", "OfficeSource", 1414.0, 0.66, 0.3, 0.3],
"COEOSF500":["Slide-Out Keyboard Tray with Palm Rest, Black", "Locks fully extended", "Reversible mouse pad", "Molded palm rest for comfort", "OfficeSource", 206.0, 1.0, -0.5, 1.5],
"COEOSF600":["Spring-Assist Keyboard Tray with Swivel Mouse, Black", "Spring assist adjusts easily", "Swivel mouse tray, either hand", "Molded palm rest for comfort", "OfficeSource", 301.0, 1.023, -1.5, 1.0],
"COEOSF6500":["Height-Adjustable Keyboard Tray, 28\" Wide, Black", "Made for sit-stand tables", "Compact arm saves knee space", "Fully retracts under desk", "OfficeSource", 649.0, 0.868, -2.2, -3.0],
"COEOSF710":["Lift & Lock Keyboard Tray, Teardrop Mouse, Black", "Gel palm rest for comfort", "Swivel teardrop mouse tray", "Sturdy 21\" track", "OfficeSource", 430.0, 1.008, -1.0, 1.0],
"COEOSF800":["Lift & Lock Keyboard Tray, Slide-Out Mouse, Black", "Locks at your ideal height", "Slide-out swivel mouse tray", "Molded palm rest for comfort", "OfficeSource", 539.0, 1.008, -1.5, 1.0],
"FEL8017801":["Designer Suites Compact Keyboard Tray, Black", "Fits smaller workspaces", "Knob sets height and tilt", "Memory foam wrist rest", "Fellowes", 289.95, 0.971, 0.5, 0.5],
"FEL8042601":["Platinum Triple Monitor Arm with USB, Black", "Gas-spring arms adjust easily", "Two USB 3.0 ports in base", "Clamp or grommet mount", "Fellowes", 466.99, 1.04, 0.5, 0.5],
"FEL8042801":["Lotus Single Monitor Arm, Silver Finish", "Made for Lotus sit-stand units", "Adjusts up to 16\" in height", "Holds monitors up to 27\"", "Fellowes", 118.99, 0.684, -1.0, 2.7],
"FEL8042901":["Lotus Dual Monitor Arm, Silver Finish", "Made for Lotus sit-stand units", "Holds two monitors up to 27\"", "Quick, easy mounting", "Fellowes", 165.6, 1.03, 0.5, 3.1],
"FEL8043701":["Freestanding Dual Monitor Arm, Black Finish", "No clamps or drilling needed", "Weighted base stays steady", "Built-in cord management", "Fellowes", 189.74, 0.93, 0.5, 0.5],
"FEL8056201":["Platinum Single Monitor Arm with USB, White", "Gas spring moves screen easily", "Two USB charging ports", "Built-in cord management", "Fellowes", 233.44, 0.66, 0.7, 0.3],
"FEL9140303":["Underdesk Keyboard Drawer, Black & Silver", "Three height settings", "Mouse tray on either side", "Memory foam wrist rests", "Fellowes", 77.03, 1.03, 0.5, 0.5],
"KTKKT165":["Clamp-On Tilting Keyboard Tray, Black", "Tilts to ease wrist strain", "Clamps on, no drilling", "Slides away when not in use", "Kantek", 97.59, 1.03, 0.5, -2.1],
"KTKMA320":["MA320 Dual Monitor Arm, Silver Aluminum & Steel", "Holds monitors up to 30\"", "Clamp or grommet mount", "Easy angle adjustments", "Kantek", 513.83, 0.66, 0.3, 0.3],
"LLR18225":["Universal Keyboard Tray, Espresso Laminate", "Fits most desks", "Slides out, tucks away", "5-year Lorell warranty", "Lorell", 189, 1.03, 0.5, 0.5],
"LLR66309":["Universal Keyboard Tray, Modern Elm Laminate", "Fits most desks", "Slides out, tucks away", "Rugged melamine laminate", "Lorell", 189, 1.035, 1.0, 0.5],
"LLR69567":["Universal Keyboard Tray, Charcoal Laminate", "Fits most desks", "Slides out, tucks away", "5-year Lorell warranty", "Lorell", 189, 1.03, 0.5, 0.5],
"LLR69992":["Universal Keyboard Tray, Walnut Laminate", "Fits most desks", "Slides out, tucks away", "Durable melamine surface", "Lorell", 189, 1.03, 0.5, 2.1],
"LLR87523":["Universal Keyboard Tray, Mahogany Laminate", "Fits most desks", "Slides out, tucks away", "5-year Lorell warranty", "Lorell", 189, 1.04, 0.5, 0.5],
"LLR87526":["Essentials Keyboard Tray, Cherry Laminate", "Fits Essentials Series desks", "Slides out, tucks away", "5-year Lorell warranty", "Lorell", 189, 1.04, 0.5, 0.5],
"LLR99543":["Adjustable Swivel Keyboard Tray Arm, Black", "Improves typing posture", "Rotates and adjusts height", "Quick under-desk install", "Lorell", 301, 0.88, 0.4, 0.4],
"MMMAKT170LE":["Sit/Stand Adjustable Keyboard Tray, Black", "Adjusts for sitting or standing", "Antimicrobial gel wrist rest", "Fits deep worksurfaces", "3M", 693.24, 1.084, 0.5, -0.5],
"MMMAKT90LE":["Easy Adjust Keyboard Tray with Mouse Platform, Black", "Adjusts up 6\", down 4\"", "Tilts and swivels 360\u00b0", "Antimicrobial gel wrist rest", "3M", 644.94, 0.985, 1.0, -5.4],
"N9NPLTPMDBLACK":["Low Profile Center Drawer, Black Metal", "Slim 2\" profile", "21.25\" wide storage", "Scratch-resistant finish", "N9N", 134.0, 1.108, 0.6, 0.6],
"N9NPLTPMDSILVER":["Low Profile Center Drawer, Silver Metal", "Slim 2\" profile", "21.25\" wide storage", "Scratch-resistant finish", "N9N", 134.0, 1.108, 0.6, 0.6],
"RCLRDM2":["Dual Monitor Desk Mount, Black Steel", "Holds two 13\" to 27\" screens", "Clamp or grommet mount", "Tilt, swivel and rotate", "Rocelco", 89, 0.714, 0.4, 0.7]
};
const DELIVERY = [
[/^COE/, '3\u20135 Day Delivery'],
[/^N9N/, '3\u20135 Day Delivery'],
[/./, '1\u20132 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 Boards cards) ----
const S = 'html body .griditems.gridlist-grid > .tileparent.product.eqs-ma';
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-ma-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-ma-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-ma-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-ma-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-ma-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-ma-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-ma-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-ma-title:hover{text-decoration:underline!important}
${S} .eqs-ma-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-ma-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-ma-dot{flex:0 0 10px!important;width:10px!important;color:rgb(67,131,70)!important}
${S} .eqs-ma-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-ma-meta > div{height:17px!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important}
${S} .eqs-ma-meta b{font-weight:600!important;color:rgb(71,85,105)!important}
${S} .eqs-ma-meta .eqs-ma-cat{font-weight:500!important;color:rgb(67,138,98)!important}
${S} .eqs-ma-meta .eqs-ma-code{letter-spacing:-.2px!important}
${S} .eqs-ma-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-ma-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-ma-list s{color:rgb(102,112,133)!important}
${S} .eqs-ma-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-ma-cents{display:block!important;margin:1px 0 0 1px!important;font:800 12px/12px Arial,sans-serif!important;letter-spacing:0!important}
${S} .eqs-ma-savings{margin:0 0 2px!important;text-align:right!important;color:rgb(100,116,139)!important;white-space:nowrap!important}
${S} .eqs-ma-savings-label{font:600 9px/12px Arial,sans-serif!important}
${S} .eqs-ma-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-ma-carticon{display:inline-flex!important;width:20px!important;height:20px!important;flex:0 0 20px!important}
${S} .eqs-ma-carticon svg{width:20px!important;height:20px!important;fill:none!important;stroke:currentColor!important;stroke-width:2!important}
${S} .eqs-ma-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-ma-brandrow .brand-label:has(img[src*="FELLOWES_LOGO"]){max-width:none!important;flex:0 0 60px!important;height:20px!important;overflow:hidden!important;align-items:flex-start!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="FELLOWES_LOGO"]) a{align-items:flex-start!important;max-width:none!important;height:20px!important;overflow:hidden!important}
${S} .eqs-ma-brandrow .brand-label img[src*="FELLOWES_LOGO"]{width:60px!important;height:60px!important;max-width:none!important;max-height:none!important;margin:-20px 0 0 0!important;object-position:left top!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="KANTEK_LOGO"]){max-width:none!important;flex:0 0 60px!important;height:22px!important;overflow:hidden!important;align-items:flex-start!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="KANTEK_LOGO"]) a{align-items:flex-start!important;max-width:none!important;height:22px!important;overflow:hidden!important}
${S} .eqs-ma-brandrow .brand-label img[src*="KANTEK_LOGO"]{width:60px!important;height:60px!important;max-width:none!important;max-height:none!important;margin:-19px 0 0 0!important;object-position:left top!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="5000353.jpg"]){max-width:none!important;flex:0 0 96px!important;height:18px!important;overflow:hidden!important;align-items:flex-start!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="5000353.jpg"]) a{align-items:flex-start!important;max-width:none!important;height:18px!important;overflow:hidden!important}
${S} .eqs-ma-brandrow .brand-label img[src*="5000353.jpg"]{width:96px!important;height:96px!important;max-width:none!important;max-height:none!important;margin:-38px 0 0 0!important;object-position:left top!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="5002712.jpg"]){max-width:none!important;flex:0 0 72px!important;height:19px!important;overflow:hidden!important;align-items:flex-start!important}
${S} .eqs-ma-brandrow .brand-label:has(img[src*="5002712.jpg"]) a{align-items:flex-start!important;max-width:none!important;height:19px!important;overflow:hidden!important}
${S} .eqs-ma-brandrow .brand-label img[src*="5002712.jpg"]{width:72px!important;height:72px!important;max-width:none!important;max-height:none!important;margin:-26px 0 0 0!important;object-position:left top!important}
${S} .product-tile-image{margin-top:11px!important}
${S} .eqs-ma-brandrow .brand-label:has(img[alt*="National Public" i]){max-width:112px!important;flex:0 0 112px!important}
${S} .eqs-ma-brandrow .brand-label:has(img[alt*="National Public" i]) a{width:100%!important}
${S} .eqs-ma-brandrow .brand-label img[alt*="National Public" i]{width:112px!important;height:auto!important;max-height:none!important;max-width:none!important}
${S} .eqs-ma-brandrow .brand-label:has(img[alt*="Global" i]),${S} .eqs-ma-brandrow .brand-label:has(img[src*="Global" i]){max-width:none!important;flex:0 0 auto!important;overflow:visible!important}
${S} .eqs-ma-brandrow .brand-label:has(img[alt*="Global" i]) a,${S} .eqs-ma-brandrow .brand-label:has(img[src*="Global" i]) a{overflow:visible!important}
${S} .eqs-ma-brandrow .brand-label img[alt*="Global" i],${S} .eqs-ma-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-ma-brandrow') || q('.eqs-p542-brandrow');
if (!row) row = el('div');
row.className = 'eqs-ma-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-ma-delivery');
if (!del) { del = el('div', 'eqs-ma-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-ma-title');
if (!title) { title = el('a', 'eqs-ma-title'); row.after(title); }
title.setAttribute('href', href);
title.textContent = d[0];
title.title = d[0];
// Bullets
let feats = q('.eqs-ma-features');
if (!feats) { feats = el('div', 'eqs-ma-features'); title.after(feats); }
feats.replaceChildren(...[d[1], d[2], d[3]].map(t => {
const f = el('div', 'eqs-ma-feature');
f.append(el('span', 'eqs-ma-dot', '\u2022'), el('span', 'eqs-ma-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 || 'Storage';
let meta = q('.eqs-ma-meta');
if (!meta) { meta = el('div', 'eqs-ma-meta'); feats.after(meta); }
const r1 = el('div'); r1.append(el('b', '', 'Category: '), el('span', 'eqs-ma-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-ma-code', sku));
meta.replaceChildren(r1, r2, r3);
// Price bar
let bar = q('.eqs-ma-pricebar');
if (!bar) {
bar = el('div', 'eqs-ma-pricebar');
const left = el('div', 'eqs-ma-left');
left.append(el('div', 'eqs-ma-list'), el('div', 'eqs-ma-price'));
const sav = el('div', 'eqs-ma-savings');
sav.append(el('div', 'eqs-ma-savings-label', 'Emerald Savings'), el('div', 'eqs-ma-savings-pct'));
bar.append(left, sav);
fw.insertBefore(bar, nativeP);
}
// Cart icon
if (!button.querySelector('.eqs-ma-carticon')) {
button.querySelector('.eqs-p542-carticon')?.remove();
const icon = el('span', 'eqs-ma-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-ma');
return true;
}
function updatePrice(card, sku, d) {
const bar = card.querySelector('.eqs-ma-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 >= (/^(COE|N9N)/.test(sku) ? MIN_DISCOUNT : BOARD_MIN_DISCOUNT) && pack === 'EA' && (!uom || uom === 'EA');
const listEl = bar.querySelector('.eqs-ma-list');
const priceEl = bar.querySelector('.eqs-ma-price');
const sav = bar.querySelector('.eqs-ma-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-ma-cents', cents));
if (perSet) priceEl.append(el('span', 'eqs-ma-per', perSet === 'set' ? 'per set' : (typeof perSet === 'string' ? perSet : '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-ma-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-ma-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-ma-title,.eqs-ma-features,.eqs-ma-meta,.eqs-ma-pricebar,.eqs-ma-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_MA = {
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-ma')).length,
withSavings: cards.filter(c => c.querySelector('.eqs-ma-savings') && c.querySelector('.eqs-ma-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-ma').forEach(c => c.classList.remove('eqs-ma'));
delete window.EQS_MA;
console.info('[EQS SEATING] Removed. Refresh to restore the original cards.');
}
};
console.info('[EQS SEATING]', VERSION, 'installed');
})();