/* EMERALD QUICK SHIP P13 AUTO SYNC V2 | SINGLE OWNED SYNCHRONIZER November 17, 2026 Replaces the contents of EQS_P13_AUTO_SYNC_TEST.js. Same file name, same position in the eight-script baseline. What it does: - Waits until the Desks grid stops changing, then runs every existing layer in a fixed order: P9 (P542, P8), P13E, Final Lock, Full Pricing Auto, V1.6.2, V1.6.3, V1.6.4, R8. - Reacts to changes inside existing cards, not only new cards, so no layer is left skipped. - Ignores its own changes, so it cannot loop. - Approved Nov 17: 140px image area on every card, closeout badges hidden, Final Lock bullets for the entire FLOS105 series. - Approved Nov 18: 19 shortened bullets so each fits on one line, and "Emerald Savings" label (was "Your Emerald Savings"). - Approved Nov 18: two-line titles (no "Finish", sizes as 66" x 30", shorter type names) and "7-10 Days" on Flash delivery labels. - V2.4 Nov 18: benefit-driven one-line bullets for every Desks product, and per-product image sizing so every product fills the same visible area (up to 180 x 128 px) and sits centered; pale gray backdrops on 6 images lifted to white. Does not change native selling prices, list prices, quantity, Add to Cart, the homepage or Footer Master. Rollback: re-upload the previous EQS_P13_AUTO_SYNC_TEST.js (or run EQS_P13_AUTO_SYNC.remove() and refresh). */ (() => { 'use strict'; if (!/^\/category\/1366566-desks(?:\.html)?\/?$/i.test(location.pathname)) return; if (window.EQS_P13_AUTO_SYNC?.active) return; const VERSION = 'P13_AUTO_SYNC_V2_7_2026_11_18'; const STYLE_ID = 'eqs-p13-sync-v2-layout'; const CARD = '.tileparent.product'; const STYLED = '.tileparent.product.eqs-p542'; const DEBOUNCE_MS = 120; const MAX_WAIT_MS = 600; const FLOS105 = /^COEDBLFLOS105[A-Z]{2}$/; const FLOS105_BULLETS = [ 'Durable laminate work surface', 'Double-pedestal storage', 'Locking file drawers' ]; /* ---------------- Consolidated layout (wins over earlier layers) ---------------- */ const S = 'html body .griditems.gridlist-grid > .tileparent.product.eqs-p542'; const style = document.createElement('style'); style.id = STYLE_ID; style.textContent = ` /* One image area for every card: 140px (approved). */ ${S} .product-tile-image, ${S} .product-tile-image .text-center, ${S} .imgthumbnail { height:140px!important; min-height:140px!important; max-height:140px!important; overflow:visible!important; } /* One title slot: two lines at 14px/19px. */ ${S} .product-name, ${S} .eqs-editorial-title, ${S} .eqs-v163-title, ${S} .eqs-v164-title { height:38px!important; min-height:38px!important; max-height:38px!important; margin:0 0 4px!important; padding:0!important; overflow:hidden!important; -webkit-line-clamp:2!important; font-family:Arial,sans-serif!important; font-size:14px!important; font-weight:700!important; line-height:19px!important; } ${S} .product-name a { font-size:14px!important; line-height:19px!important; } /* Bullets: 12px/16px on every card, three-line slot. */ ${S} .eqs-p13e-features { min-height:48px!important; margin:0 0 4px!important; padding:0!important; gap:0!important; } ${S} .eqs-p13e-feature, ${S} .eqs-v162-copy, ${S} .eqs-v163-copy, ${S} .eqs-v164-copy, ${S} .eqs-v162-dot, ${S} .eqs-v163-dot, ${S} .eqs-v164-dot { font-size:12px!important; line-height:16px!important; } ${S} > .tile { padding-left:14px!important; padding-right:14px!important; } ${S} .eqs-p13e-feature { gap:5px!important; } ${S} .eqs-p13e-feature::before { line-height:16px!important; } /* CCC slot: room for Category, Collection, Item Code. */ ${S} .eqs-p13e-meta { min-height:51px!important; } /* Closeout badges hidden on Desks (approved). */ html body .tileparent.product .emerald-closeout-deal-badge, ${S} .eqs-r6-price-line .emerald-closeout-deal-badge { display:none!important; } `; document.head.appendChild(style); /* ---------------- State ---------------- */ let active = true; let timer = null; let firstAt = 0; let runs = 0; let lastReason = ''; let lastRunMs = 0; let pausedUntil = 0; const recent = []; const errors = []; const skuOf = card => (card.dataset.sku || '').trim().toUpperCase(); function call(label, fn) { try { return fn(); } catch (e) { if (errors.length < 20) errors.push(label + ': ' + (e && e.message)); console.warn('[P13 SYNC V2]', label, e); } } // Cards P13E can build now but has not built yet. function p13eBuildable() { let n = 0; for (const card of document.querySelectorAll(STYLED)) { if (card.querySelector('.eqs-p13e-features')) continue; const price = card.querySelector('.footer-wrapper-price'); if (card.querySelector('.eqs-p542-description') && price && price.parentNode && card.querySelector('.product-sku')) n++; } return n; } // V2.4: benefit-driven bullets by product family (first match wins). const BENEFIT_BULLETS = [ [/^COECOSMO4/, ["Glass counter greets visitors", "L-shape adds extra work space", "Durable laminate wipes clean"]], [/^COECOSMO6/, ["Glass counter impresses guests", "ADA return aids accessibility", "Easy-clean surfaces stay sharp"]], [/^COEDBLFDOS/, ["Durable laminate resists wear", "Locking pedestals secure files", "Pairs with OS Laminate storage"]], [/^COEDBLFLOS10[123]/, ["Sets up left- or right-handed", "Pairs with OS Laminate storage", "Premium laminate built to last"]], [/^COEDBLFLOS105/, ["Durable laminate resists wear", "Double pedestals add storage", "Locking drawers secure files"]], [/^COEEV6030/, ["L-shape spreads out your work", "Double pedestals add storage", "Pairs with Palisades Collection"]], [/^COEEVRC1/, ["Glass counter greets visitors", "Creates a welcoming front desk", "Pairs with Palisades Collection"]], [/^COEFL689/, ["Grommets keep cords tidy", "Kneespace for seated work", "Pairs with Markle Collection"]], [/^COEIDD3060/, ["Industrial metal-corner style", "Rectangular top fits any office", "Rich Distressed Brown finish"]], [/^COEIDD3072/, ["Industrial metal-corner style", "Spacious top spreads out work", "Rich Distressed Brown finish"]], [/^COEMARKLE/, ["Drawer stows your keyboard", "Grommets keep cords tidy", "Locking drawers secure files"]], [/^COEMNC680/, ["Roomy 66\" executive top", "Stone-look laminate adds style", "Pairs with Artisan Collection"]], [/^COEMNC689/, ["Kneespace for seated work", "Stone-look laminate adds style", "Pairs with Artisan Collection"]], [/^COEMNM680/, ["Roomy 66\" executive top", "Warm wood-look laminate finish", "Pairs with Artisan Collection"]], [/^COEMNM689/, ["Kneespace for seated work", "Warm wood-look laminate finish", "Pairs with Artisan Collection"]], [/^COEOS169NTT/, ["Makes a strong first impression", "Clean, professional styling", "Transaction top sold separately"]], [/^COEOS169TTGLASS/, ["Smooth counter for check-in", "Glass top adds modern polish", "Metal risers included"]], [/^COEOS169TT/, ["Smooth counter for check-in", "Durable laminate resists wear", "Metal risers included"]], [/^COEOSTHAT5172WH/, ["Roomy laminate work surface", "Electric lift to sit or stand", "Antimicrobial top stays cleaner"]], [/^COEOSTHAT5172/, ["Roomy laminate work surface", "Electric lift to sit or stand", "Set your ideal work height"]], [/^COESGLHDOS121/, ["Durable laminate resists wear", "Locking pedestal secures files", "Pairs with OS Laminate storage"]], [/^FLANANCDGGJ$/, ["Wraps workspace into a corner", "L-shape saves floor space", "Great for home office or gaming"]], [/^FLANANJN2824SLJ$/, ["Sleek black glass surfaces", "Corner design saves space", "Pull-out tray frees desk space"]], [/^FLANANWK004$/, ["Durable black laminate top", "Pull-out tray frees desk space", "Cross-braced for stability"]], [/^FLANANWK055J$/, ["Sleek glass top looks modern", "Built-in pedestal adds storage", "Sturdy metal frame for stability"]], [/^N9NCLALD1056/, ["White counter greets guests", "Fits a 73\" x 72\" reception area", "L-shape adds extra work space"]], [/^N9NPL245/, ["Set drawers left or right", "Sliding doors save aisle space", "Locking drawers secure files"]], [/^N9NRISLD/, ["L-shape spreads out your work", "Crisp white base looks modern", "Modesty panels add privacy"]], [/^N9NRISSD/, ["Durable laminate work surface", "Crisp white base looks modern", "Modesty panels add privacy"]], [/^N9NRISUD/, ["U-shape keeps work in reach", "Crisp white base looks modern", "Modesty panels add privacy"]], [/^OTGLAYOUTSL13/, ["Sets up left- or right-handed", "Durable laminate resists wear", "Matching storage keeps it tidy"]], [/^OTGLAYOUTSL14/, ["U-shape sets up left or right", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL15/, ["U-shape sets up left or right", "Hutch adds overhead storage", "Locking files protect documents"]], [/^OTGLAYOUTSL16/, ["Bowfront welcomes guests", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL17/, ["Bowfront welcomes guests", "Hutch adds overhead storage", "Premium laminate built to last"]], [/^OTGLAYOUTSL18/, ["Peninsula top for side meetings", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL19/, ["Peninsula top for side meetings", "Locking files protect documents", "Hutch adds overhead storage"]], [/^OTGLAYOUTSL1[A-Z]/, ["Durable laminate resists wear", "Acrylic panel adds privacy", "Locking mobile file pedestal"]], [/^OTGLAYOUTSL2[A-Z]/, ["Modesty panel adds privacy", "Credenza, hutch add storage", "Locking drawers secure files"]], [/^OTGLAYOUTSL2[23]/, ["Bowfront welcomes guests", "Credenza, hutch add storage", "Locking files protect documents"]], [/^OTGLAYOUTSL24/, ["Peninsula top for side meetings", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL25/, ["L-shape spreads out your work", "Locking files protect documents", "Hutch adds overhead storage"]], [/^OTGLAYOUTSL26/, ["L-shape sets up left or right", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL27/, ["L-shape sets up left or right", "Locking files protect documents", "Locking lateral file adds space"]], [/^OTGLAYOUTSL28/, ["Reverses to fit your lobby", "Counter greets visitors", "Premium laminate built to last"]], [/^OTGLAYOUTSL30/, ["Spacious top spreads out work", "Full-file drawers hold folders", "Premium laminate built to last"]], [/^OTGLAYOUTSL31/, ["Spacious top spreads out work", "Hanging files keep papers neat", "Premium laminate built to last"]], [/^OTGLAYOUTSL32/, ["L-shape sets up left or right", "Locking files protect documents", "Premium laminate built to last"]], [/^OTGLAYOUTSL33/, ["Spacious top spreads out work", "Locking files protect documents", "Premium laminate built to last"]] ]; // V2.4: per-product image scale and centering [scale, x px, y px]. const IMAGE_FIT = {"COECOSMO4CB":[0.973,-1.5,3.9],"COECOSMO4SG":[0.973,-1.5,3.9],"COECOSMO6CB":[1.059,0,-1.6],"COECOSMO6SG":[1.006,0.5,0],"COEDBLFDOS102AE":[1.098,-1.1,-5.5],"COEDBLFDOS102AR":[1.104,0.6,-5],"COEDBLFDOS102CG":[1.098,0,-4.9],"COEDBLFDOS102CH":[1.091,0.5,-4.9],"COEDBLFDOS102ES":[1.091,0.5,-4.9],"COEDBLFDOS102JV":[1.098,0,-5.5],"COEDBLFDOS102MA":[1.084,0,-6],"COEDBLFDOS102MH":[1.078,-0.5,-4.9],"COEDBLFDOS102MW":[1.084,1.1,-4.9],"COEDBLFDOS102WH":[1.098,1.1,-6],"COEDBLFDOS103AE":[0.989,-2,-4.9],"COEDBLFDOS103AR":[0.994,-1.5,-4.5],"COEDBLFDOS103CG":[0.994,-1.5,-5],"COEDBLFDOS103CH":[0.989,-1,-4.5],"COEDBLFDOS103ES":[0.989,-1,-4.5],"COEDBLFDOS103JV":[0.994,-1.5,-5],"COEDBLFDOS103MA":[0.989,-1,-4.5],"COEDBLFDOS103MH":[0.989,-1,-4.5],"COEDBLFDOS103MW":[0.989,-1,-4.9],"COEDBLFDOS103WH":[0.989,-1,-5.9],"COEDBLFDOS105AE":[1.023,-1,-12.3],"COEDBLFDOS105AR":[1.04,-0.5,-12],"COEDBLFDOS105CG":[1.034,0,-11.9],"COEDBLFDOS105CH":[1.029,0.5,-11.3],"COEDBLFDOS105JV":[1.029,-0.5,-11.3],"COEDBLFDOS105MA":[1.034,0,-11.9],"COEDBLFDOS105MH":[1.029,0.5,-11.3],"COEDBLFDOS105MW":[1.034,0,-11.4],"COEDBLFDOS105WH":[1.047,0,-12.6],"COEDBLFLOS101AE":[0.984,-0.5,-4.4],"COEDBLFLOS101AR":[0.989,-1,-4.9],"COEDBLFLOS101CG":[0.984,-1.5,-5.4],"COEDBLFLOS101CH":[0.978,-1,-5.4],"COEDBLFLOS101ES":[0.984,-1.5,-4.9],"COEDBLFLOS101JV":[0.989,-1,-4.9],"COEDBLFLOS101MA":[0.978,-1,-5.4],"COEDBLFLOS101MH":[0.984,-1.5,-5.4],"COEDBLFLOS101MW":[0.978,-1,-5.4],"COEDBLFLOS101WH":[0.989,-1,-6.4],"COEDBLFLOS102AE":[0.994,-0.5,-4],"COEDBLFLOS102AR":[0.994,-0.5,-4],"COEDBLFLOS102CG":[0.994,-0.5,-4],"COEDBLFLOS102CH":[0.984,-0.5,-4.4],"COEDBLFLOS102ES":[0.984,-0.5,-3.9],"COEDBLFLOS102JV":[0.994,-0.5,-4],"COEDBLFLOS102MA":[0.989,-1,-4.5],"COEDBLFLOS102MH":[0.984,-0.5,-3.9],"COEDBLFLOS102MW":[0.984,-0.5,-4.4],"COEDBLFLOS102WH":[0.994,-0.5,-4.5],"COEDBLFLOS103AE":[0.947,-0.9,-2.8],"COEDBLFLOS103AR":[0.989,1,-4.9],"COEDBLFLOS103CG":[0.952,-1.4,-2.9],"COEDBLFLOS103CH":[0.947,-1.9,-2.8],"COEDBLFLOS103ES":[0.952,-1.4,-2.9],"COEDBLFLOS103JV":[0.957,-1,-2.9],"COEDBLFLOS103MA":[0.952,-1.4,-2.9],"COEDBLFLOS103MH":[0.952,-1.4,-2.9],"COEDBLFLOS103MW":[0.952,-1.4,-2.9],"COEDBLFLOS103WH":[0.963,-0.5,-3.4],"COEDBLFLOS105AE":[0.957,-1,-3.8],"COEDBLFLOS105AR":[0.963,-0.5,-3.9],"COEDBLFLOS105CG":[0.957,-1,-3.8],"COEDBLFLOS105CH":[0.957,-1,-3.8],"COEDBLFLOS105JV":[0.957,-1,-3.8],"COEDBLFLOS105MH":[0.957,-1,-3.8],"COEDBLFLOS105MW":[0.957,-1,-3.8],"COEDBLFLOS105WH":[0.968,0,-4.4],"COEEV6030LGG":[1.034,0,-23.3],"COEEVRC1LGG":[1.011,1,-5.6],"COEFL689RE":[0.923,-0.5,-0.5],"COEIDD3060DB":[0.942,-0.5,-2.4],"COEDBLFLOS105MA":[0.973,0.5,-4.9],"COEIDD3072DB":[0.947,0,-3.8],"COEMARKLE68W":[0.81,-0.4,0],"COEMNC680CT":[1.04,0.5,-15.1],"COEMNC689CT":[0.81,1.2,0],"COEMNM680NA":[1.04,0.5,-14],"COEMNM689NA":[0.938,0,0],"COEOS169NTTAE":[0.962,0,-2.4],"COEOS169NTTAR":[0.97,0,-2.9],"COEOS169NTTCG":[0.955,-0.5,-2.9],"COEOS169NTTCH":[0.955,-1.4,-2.9],"COEOS169NTTES":[0.941,0,-1.9],"COEOS169NTTJV":[0.97,0,-2.9],"COEOS169NTTMA":[0.955,-0.5,-2.9],"COEOS169NTTMH":[0.941,0,-1.9],"COEOS169NTTMW":[0.955,-0.5,-2.9],"COEOS169NTTWH":[0.955,0,-2.9],"COEOS169TTAE":[1.006,0.5,8],"COEOS169TTAR":[1.017,0.5,7.6],"COEOS169TTCG":[1.006,0.5,7.5],"COEOS169TTCH":[1,0,6.5],"COEOS169TTGLASSWH":[0.928,0,3.2],"COEOS169TTJV":[1.017,0.5,7.6],"COEOS169TTMA":[0.994,0.5,8],"COEOS169TTMH":[1,0,6.5],"COEOS169TTMW":[1.006,0.5,7],"COEOS169TTWH":[1.006,0.5,6],"COEOSTHAT5172AEETC":[0.938,-0.9,-7.5],"COEOSTHAT5172CGETC":[0.963,0.5,-7.2],"COEOSTHAT5172JVETC":[1.059,1.1,-1.6],"COEOSTHAT5172MAETC":[1.053,0.5,-5.8],"COEOSTHAT5172MHETC":[0.918,-0.9,-7.3],"COEOSTHAT5172MWETC":[0.989,-4.9,-1],"COEOSTHAT5172WHETC":[0.989,0,-7.4],"COESGLHDOS121AE":[0.928,-2.3,-4.6],"COESGLHDOS121AR":[0.955,-1.4,-3.8],"COESGLHDOS121CG":[0.941,-2.4,-4.7],"COESGLHDOS121CH":[0.934,-0.9,-4.2],"COESGLHDOS121ES":[0.934,-2.3,-4.2],"COESGLHDOS121JV":[0.948,-0.5,-4.3],"COESGLHDOS121MA":[0.934,-1.9,-4.2],"COESGLHDOS121MH":[0.934,-2.3,-4.2],"COESGLHDOS121MW":[0.941,-2.4,-4.7],"COESGLHDOS121WH":[0.955,-1.9,-5.7],"FLANANCDGGJ":[0.914,-0.5,-0.9],"FLANANJN2824SLJ":[0.928,0,-6],"FLANANWK004":[0.865,0,-0.9],"FLANANWK055J":[0.859,-0.4,-3],"N9NCLALD1056AP":[1.006,0.5,0.5],"N9NCLALD1056ES":[1.011,-3,0.5],"N9NCLALD1056MW":[0.994,-1.5,0.5],"N9NCLALD1056NPG":[1.011,1,1],"N9NCLALD1056SLB":[0.978,0,0],"N9NPL245APN":[0.977,0,-0.5],"N9NPL245CG":[0.968,0,0],"N9NPL245ESP":[0.973,0.5,-0.5],"N9NRISLD1000AS":[0.968,0,0.5],"N9NRISLD1000CG":[0.968,0,0.5],"N9NRISLD1000CH":[0.938,0,-4.2],"N9NRISLD1000ES":[0.968,0,0.5],"N9NRISLD1000MW":[0.968,0,0.5],"N9NRISLD1000NG":[0.968,0,0.5],"N9NRISLD1000SB":[0.968,0,0],"N9NRISSD1000AS":[0.968,0,1],"N9NRISSD1000CG":[0.963,0.5,1],"N9NRISSD1000CH":[0.968,0,-6.3],"N9NRISSD1000ES":[0.968,0,-6.3],"N9NRISSD1000MW":[0.968,0,-6.3],"N9NRISSD1000NG":[0.963,0.5,1],"N9NRISSD1000SB":[0.968,0,0.5],"N9NRISUD1003AS":[0.963,-0.5,-6.7],"N9NRISUD1003CG":[0.963,0.5,0.5],"N9NRISUD1003CH":[0.957,0,-6.2],"N9NRISUD1003ES":[0.957,0,-5.7],"N9NRISUD1003MW":[0.957,0,-5.7],"N9NRISUD1003NG":[0.968,0,0.5],"N9NRISUD1003SB":[0.957,0,-6.7],"OTGLAYOUTSL13ADC":[1.286,-10.3,3.2],"OTGLAYOUTSL13AEL":[1.241,-6.2,3.1],"OTGLAYOUTSL13AGL":[1.304,-13.7,4.6],"OTGLAYOUTSL13AML":[1.263,-8.5,2.8],"OTGLAYOUTSL13AWL":[1.333,-4.7,4],"OTGLAYOUTSL14ADC":[1.299,0,1.3],"OTGLAYOUTSL14AEL":[1.299,-0.3,1.3],"OTGLAYOUTSL14AGL":[1.306,-0.3,1.6],"OTGLAYOUTSL14AML":[1.299,-0.3,1.3],"OTGLAYOUTSL14AWL":[1.306,-0.3,1.6],"OTGLAYOUTSL15ADC":[1.274,0,0],"OTGLAYOUTSL15AEL":[1.274,0,0],"OTGLAYOUTSL15AGL":[1.274,0,0],"OTGLAYOUTSL15AML":[1.274,0,0],"OTGLAYOUTSL15AWL":[1.274,0,0],"OTGLAYOUTSL16ADC":[1.353,-4.1,5.1],"OTGLAYOUTSL16AEL":[1.379,-4.5,6.2],"OTGLAYOUTSL16AGL":[1.358,-3.1,5.1],"OTGLAYOUTSL16AML":[1.364,-4.8,5.5],"OTGLAYOUTSL16AWL":[1.374,-4.1,5.8],"OTGLAYOUTSL17ADC":[1.347,-9.8,3.7],"OTGLAYOUTSL17AEL":[1.354,-10.2,4.1],"OTGLAYOUTSL17AGL":[1.354,-7.4,4.1],"OTGLAYOUTSL17AML":[1.362,-9.9,4.4],"OTGLAYOUTSL17AWL":[1.362,-9.5,4.4],"OTGLAYOUTSL18ADC":[1.299,0,1.3],"OTGLAYOUTSL18AEL":[1.2,0,1.2],"OTGLAYOUTSL18AGL":[1.2,0,1.2],"OTGLAYOUTSL18AML":[1.2,0,1.2],"OTGLAYOUTSL18AWL":[1.2,0,1.2],"OTGLAYOUTSL19ADC":[1.299,0,1.3],"OTGLAYOUTSL19AEL":[1.293,0,1],"OTGLAYOUTSL19AGL":[1.293,0,1],"OTGLAYOUTSL19AML":[1.293,0,1],"OTGLAYOUTSL19AWL":[1.293,0,1],"OTGLAYOUTSL1ADC":[1.313,2,2],"OTGLAYOUTSL1AEL":[1.313,2,2],"OTGLAYOUTSL1AGL":[1.313,2,2],"OTGLAYOUTSL1AML":[1.313,2,2],"OTGLAYOUTSL1AWL":[1.32,2,2.3],"OTGLAYOUTSL22ADC":[1.274,0,0],"OTGLAYOUTSL22AEL":[1.274,0,0],"OTGLAYOUTSL22AGL":[1.274,-0.3,0],"OTGLAYOUTSL22AML":[1.274,-0.3,0],"OTGLAYOUTSL22AWL":[1.274,-0.3,0],"OTGLAYOUTSL23ADC":[1.274,0,0],"OTGLAYOUTSL23AEL":[1.274,0,0],"OTGLAYOUTSL23AGL":[1.286,0,0.6],"OTGLAYOUTSL23AML":[1.274,0,0],"OTGLAYOUTSL23AWL":[1.274,0.3,0],"OTGLAYOUTSL24ADC":[1.25,1.3,1.9],"OTGLAYOUTSL24AEL":[1.254,1.6,1.9],"OTGLAYOUTSL24AGL":[1.246,1.6,1.9],"OTGLAYOUTSL24AML":[1.254,1.6,1.9],"OTGLAYOUTSL24AWL":[1.263,1.6,2.2],"OTGLAYOUTSL25ADC":[1.299,0,1.3],"OTGLAYOUTSL25AEL":[1.299,0.3,1.3],"OTGLAYOUTSL25AGL":[1.299,-0.3,1.3],"OTGLAYOUTSL25AML":[1.299,0,1.3],"OTGLAYOUTSL25AWL":[1.313,0,2],"OTGLAYOUTSL26ADC":[1.165,0.3,2],"OTGLAYOUTSL26AEL":[1.161,0,1.7],"OTGLAYOUTSL26AGL":[1.154,0,1.7],"OTGLAYOUTSL26AML":[1.161,0,1.7],"OTGLAYOUTSL26AWL":[1.173,0.3,2.1],"OTGLAYOUTSL27ADC":[1.104,0,1.4],"OTGLAYOUTSL27AEL":[1.111,0,1.7],"OTGLAYOUTSL27AGL":[1.108,0.3,1.7],"OTGLAYOUTSL27AML":[1.108,-0.3,1.7],"OTGLAYOUTSL27AWL":[1.111,0.6,1.9],"OTGLAYOUTSL28ADC":[1.299,0,1.3],"OTGLAYOUTSL28AEL":[1.306,0.3,1.6],"OTGLAYOUTSL28AGL":[1.306,0,1.6],"OTGLAYOUTSL28AML":[1.306,0.3,1.6],"OTGLAYOUTSL28AWL":[1.313,0,1.3],"OTGLAYOUTSL2ADC":[1.299,-0.6,1.3],"OTGLAYOUTSL2AEL":[1.293,-0.6,1],"OTGLAYOUTSL2AGL":[1.293,-0.6,1],"OTGLAYOUTSL2AML":[1.293,-0.6,1],"OTGLAYOUTSL2AWL":[1.299,-0.6,1.3],"OTGLAYOUTSL30ADC":[1.313,0.3,2],"OTGLAYOUTSL30AEL":[1.313,0.3,2],"OTGLAYOUTSL30AGL":[1.34,0.7,3.4],"OTGLAYOUTSL30AML":[1.313,0.3,2],"OTGLAYOUTSL30AWL":[1.313,0,2],"OTGLAYOUTSL31ADC":[1.306,0,1.6],"OTGLAYOUTSL31AEL":[1.313,0,2],"OTGLAYOUTSL31AGL":[1.313,0,2],"OTGLAYOUTSL31AML":[1.313,0,2],"OTGLAYOUTSL31AWL":[1.313,0.3,2],"OTGLAYOUTSL32ADC":[1.139,0,1.7],"OTGLAYOUTSL32AEL":[1.139,0,1.7],"OTGLAYOUTSL32AGL":[1.146,-0.6,2],"OTGLAYOUTSL32AML":[1.146,0,1.7],"OTGLAYOUTSL32AWL":[1.158,-0.3,1.7],"OTGLAYOUTSL33ADC":[1.326,0,1.3],"OTGLAYOUTSL33AEL":[1.313,0,2],"OTGLAYOUTSL33AGL":[1.326,0,1.3],"OTGLAYOUTSL33AML":[1.32,0,1.6],"OTGLAYOUTSL33AWL":[1.326,0.7,1.3]}; // V2.4: lift pale gray backdrops to white on the few images that have one. const BG_LIFT = {"COEMNC680CT":1.04,"OTGLAYOUTSL13ADC":1.055,"OTGLAYOUTSL13AEL":1.055, "OTGLAYOUTSL13AGL":1.055,"OTGLAYOUTSL13AML":1.055,"OTGLAYOUTSL13AWL":1.04}; // V2.4: per-product image sizing rules. const imageStyle = document.createElement('style'); imageStyle.id = 'eqs-p13-sync-v24-images'; imageStyle.textContent = Object.entries(IMAGE_FIT).map(([sku, [k, x, y]]) => `${S}[data-sku="${sku}"] .product-tile-image img{transform:translate(${x}px,${y}px) scale(${k})!important;transform-origin:center center!important${BG_LIFT[sku] ? `;filter:brightness(${BG_LIFT[sku]})!important` : ''}}` ).join('\n'); document.head.appendChild(imageStyle); // Approved Nov 18: shortened bullets so every line fits at 12px. const SHORT_BULLETS = Object.freeze({ 'Durable laminate is easy to maintain': 'Easy-care durable laminate', 'Durable, easy-clean work surfaces': 'Durable, easy-clean surfaces', 'Coordinates with Palisades Collection': 'Matches Palisades Collection', 'Built-in wire-management grommets': 'Built-in wire grommets', 'Coordinates with Markle Collection': 'Matches Markle Collection', 'Rectangular laminate work surface': 'Rectangular laminate surface', 'Spacious rectangular work surface': 'Spacious rectangular surface', 'Coordinates with Artisan Collection': 'Matches Artisan Collection', 'Smooth surface for visitor interactions': 'Smooth surface for visitors', 'Adjustable height for ergonomic comfort': 'Adjusts for ergonomic comfort', 'Antimicrobial white laminate surface': 'Antimicrobial white laminate', 'Coordinates with OS Laminate storage': 'Matches OS Laminate storage', 'Reversible drawer and cabinet layout': 'Reversible drawers and cabinet', 'Sliding doors for convenient access': 'Sliding doors for easy access', 'Locking drawers for secure storage': 'Secure locking drawers', 'Reversible U-shaped configuration': 'Reversible U-shaped layout', 'Bowfront surface welcomes guests': 'Bowfront welcomes guests', 'Credenza and hutch organize supplies': 'Credenza and hutch storage', 'Matching credenza and storage hutch': 'Matching credenza and hutch' }); // Approved Nov 18: two-line titles. Keeps type, size and full finish name. const TITLE_PREFIXES = [ ['Straight Double-Pedestal Desk,', 'Double-Pedestal Desk,'], ['L-Shaped Double-Pedestal Desk,', 'Double-Pedestal L-Desk,'], ['Reception Desk Transaction Top,', 'Reception Transaction Top,'], ['U-Shaped Peninsula Desk,', 'U-Peninsula Desk,'], ['U-Shaped Peninsula & Hutch,', 'U-Peninsula & Hutch,'], ['L-Shaped Peninsula Desk,', 'L-Peninsula Desk,'], ['Reversible L-Shaped Desk,', 'Reversible L-Desk,'], ['L-Shaped Desk & Lateral File,', 'L-Desk & Lateral File,'], ['L-Shaped Reception Desk,', 'L-Reception Desk,'] ]; // Shorter type names only for the families whose titles did not fit. const SHORT_TYPE_SKUS = /^(OTGLAYOUT|COEDBLF|COEOS169TT)/; const LAMINATE_SUFFIX_SKUS = new Set(['COEMNC680CT', 'N9NCLALD1056AP', 'N9NRISLD1000AS', 'N9NRISLD1000CH', 'N9NRISUD1003AS']); const FINISH_KEEP_SKUS = new Set(['COEMNC689CT']); function shortTitle(text, sku) { let t = text.trim() .replace(/(\d+(?:\.\d+)?)"W x (\d+(?:\.\d+)?)"D/g, '$1" x $2"') .replace(/ Finish$/, ''); // Approved Nov 18: keep the finish word on these titles. if (FINISH_KEEP_SKUS.has(sku)) return t + ' Finish'; // Approved Nov 18: the five one-line titles get a finish suffix for two lines. if (LAMINATE_SUFFIX_SKUS.has(sku)) return t.replace(/ Laminate$/, '') + ' Laminate Finish'; if (!SHORT_TYPE_SKUS.test(sku)) return t; for (const [from, to] of TITLE_PREFIXES) { if (t.startsWith(from)) { t = to + t.slice(from.length); break; } } return t; } // Approved Nov 18: Flash delivery label shortened to fit beside the logo. const FLASH_DELIVERY = '7\u201310 Days'; function setFlashDelivery(card) { const badge = card.querySelector('.eqs-p542-delivery'); if (!badge) return; const walker = document.createTreeWalker(badge, NodeFilter.SHOW_TEXT); let node; while ((node = walker.nextNode())) { if (node.parentElement?.closest('svg')) continue; if (/delivery|day/i.test(node.textContent)) { if (node.textContent !== FLASH_DELIVERY) node.textContent = FLASH_DELIVERY; return; } } } function enforcePolicy() { for (const title of document.querySelectorAll( STYLED + ' .eqs-editorial-title, ' + STYLED + ' .eqs-v163-title, ' + STYLED + ' .eqs-v164-title')) { const short = shortTitle(title.textContent, skuOf(title.closest(CARD))); if (title.textContent !== short) title.textContent = short; } for (const card of document.querySelectorAll(STYLED + '[data-sku^="FLA"]')) setFlashDelivery(card); // Approved Nov 18: shorter savings label, clear of the raised cents. for (const label of document.querySelectorAll(STYLED + ' .eqs-r2-label')) { if (label.textContent.trim() === 'Your Emerald Savings') label.textContent = 'Emerald Savings'; } for (const card of document.querySelectorAll(STYLED)) { const nodes = [...card.querySelectorAll('.eqs-p13e-features .eqs-p13e-feature')]; const sku = skuOf(card); const fam = BENEFIT_BULLETS.find(([re]) => re.test(sku)); const want = fam ? fam[1] : (FLOS105.test(sku) ? FLOS105_BULLETS : null); if (want && nodes.length === 3) { nodes.forEach((node, i) => { const target = node.querySelector('.eqs-v162-copy, .eqs-v163-copy, .eqs-v164-copy') || node; if (target.textContent !== want[i]) target.textContent = want[i]; }); continue; } for (const node of nodes) { const target = node.querySelector('.eqs-v162-copy, .eqs-v163-copy, .eqs-v164-copy') || node; const short = SHORT_BULLETS[target.textContent.trim()]; if (short) target.textContent = short; } } } function connect() { observer.observe(document.body, { childList:true, subtree:true, characterData:true, attributes:true, attributeFilter:['data-value','data-sku'] }); } /* ---------------- Ordered pipeline ---------------- */ function run(reason) { if (!active) return; const now = performance.now(); if (now < pausedUntil) { schedule(reason); return; } // Safety brake: never more than 30 runs in 10 seconds. recent.push(now); while (recent.length && now - recent[0] > 10000) recent.shift(); if (recent.length > 30) { pausedUntil = now + 3000; console.warn('[P13 SYNC V2] Unusual activity, pausing 3 seconds.'); schedule('resume'); return; } observer.disconnect(); const t0 = performance.now(); let rescanned = false; try { call('P542', () => window.EQS_P542?.scan?.()); call('P8', () => window.EQS_P8?.rescan?.()); if (p13eBuildable() > 0) { call('P13E', () => window.EQS_P13E?.rescan?.()); rescanned = true; } call('FINAL', () => window.EQS_P13_FINAL?.rescan?.()); call('FULL_AUTO', () => window.EQS_P13_FULL_AUTO?.rescan?.()); call('V162', () => window.EQS_EDITORIAL_V162?.apply?.()); call('V163', () => window.EQS_EDITORIAL_V163_ADDON?.apply?.()); call('V164', () => window.EQS_EDITORIAL_V164_ADDON?.apply?.()); call('R8', () => window.EQS_DESKS_R8?.apply?.()); call('POLICY', enforcePolicy); } finally { runs++; lastReason = reason; lastRunMs = Math.round(performance.now() - t0); if (active) connect(); } // P13E.rescan also queues a delayed V1.6.2 pass (two frames later). // Re-apply the FLOS105 policy right after it, before the next paint. if (rescanned) { requestAnimationFrame(() => requestAnimationFrame(() => { if (!active) return; observer.disconnect(); call('POLICY', enforcePolicy); connect(); })); } } function schedule(reason) { if (!active) return; const now = performance.now(); if (timer === null) firstAt = now; else clearTimeout(timer); const wait = Math.max(0, Math.min(DEBOUNCE_MS, MAX_WAIT_MS - (now - firstAt))); timer = setTimeout(() => { timer = null; run(reason); }, wait); } function relevant(m) { const el = m.target.nodeType === 1 ? m.target : m.target.parentElement; if (el?.closest?.(CARD)) return true; if (m.type === 'childList') { for (const n of m.addedNodes) { if (n.nodeType === 1 && (n.matches?.(CARD) || n.querySelector?.(CARD))) return true; } for (const n of m.removedNodes) { if (n.nodeType === 1 && (n.matches?.(CARD) || n.querySelector?.(CARD))) return true; } } return false; } const observer = new MutationObserver(mutations => { if (mutations.some(relevant)) schedule('grid change'); }); connect(); /* ---------------- Status (read-only) ---------------- */ function status() { const cards = [...document.querySelectorAll(STYLED)] .filter(c => c.dataset.eqsEmptyShell !== '1'); const notBuilt = [], fewerThanThree = [], wrapped = [], stale = []; for (const card of cards) { const sku = skuOf(card); const feats = [...card.querySelectorAll('.eqs-p13e-features .eqs-p13e-feature')]; if (!card.querySelector('.eqs-p13e-features')) { notBuilt.push(sku); continue; } if (feats.length < 3) fewerThanThree.push(sku); if (feats.some(f => f.getBoundingClientRect().height > 20)) wrapped.push(sku); const codeRow = [...card.querySelectorAll('.eqs-p13e-meta > div')] .find(r => /^Item Code/i.test(r.textContent.trim())); const code = codeRow?.querySelector('span')?.textContent.trim().toUpperCase(); if (code && sku && code !== sku) stale.push(sku); } return { version:VERSION, active, runs, lastReason, lastRunMs, nativeCards:document.querySelectorAll(CARD).length, styledCards:cards.length, notBuiltByP13E:notBuilt, fewerThanThreeBullets:fewerThanThree, wrappedBullets:wrapped, staleCards:stale, closeoutBadgesHidden:document.querySelectorAll(CARD + ' .emerald-closeout-deal-badge').length, pricingOverlays:document.querySelectorAll('.eqs-r2-pricebar, .eqs-v164-pricebar').length, cartButtons:document.querySelectorAll(CARD + ' .btn-add-to-cart').length, errors:[...errors] }; } function remove() { active = false; observer.disconnect(); clearTimeout(timer); style.remove(); imageStyle.remove(); delete window.EQS_P13_AUTO_SYNC; console.info('[P13 SYNC V2] Removed. Refresh to restore previous card text.'); } window.EQS_P13_AUTO_SYNC = { active:true, version:VERSION, status, rescan:() => run('manual'), remove }; // Later scripts (R8) are not loaded yet; the first run waits for them. schedule('init'); window.addEventListener('load', () => schedule('page load')); console.info('[P13 SYNC V2] Active.'); })();