document.addEventListener('DOMContentLoaded', function () { // FIX 1: H2 heading — make descriptive for screen readers var heading = document.getElementById('s-lch-welcome'); if (heading) { heading.textContent = 'Library Live Chat — 24/7 Chat'; } // FIX 2: Asterisk — replace * with (required) document.querySelectorAll('label.form-label').forEach(function (label) { if (label.textContent.includes('*')) { // Remove bare * from text nodes label.childNodes.forEach(function (node) { if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('*')) { node.textContent = node.textContent.replace('*', ''); } }); // Hide * if it's wrapped in a span/abbr label.querySelectorAll('span, abbr').forEach(function (el) { if (el.textContent.trim() === '*') { el.setAttribute('aria-hidden', 'true'); el.style.display = 'none'; } }); // Append visible (required) text var req = document.createElement('span'); req.textContent = ' (required)'; label.appendChild(req); } }); // FIX 3: NVDA double-announcement — remove redundant title var topBarControls = [ '#s-lch-sound', '#s-lch-close', '[title="Sound on"]', '[title="Sound off"]', '[title="Close chat"]', '.lch-header button', '.lch-header a' ]; topBarControls.forEach(function (sel) { document.querySelectorAll(sel).forEach(function (el) { el.removeAttribute('title'); }); }); // FIX 4: NVDA double-announcement during active chat — var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { mutation.addedNodes.forEach(function (node) { if (node.nodeType === 1) { // Strip title from the new node itself if (node.hasAttribute && node.hasAttribute('title')) { var tag = node.tagName.toLowerCase(); if (tag === 'button' || tag === 'a') { node.removeAttribute('title'); } } // Strip title from any children node.querySelectorAll && node.querySelectorAll('button[title], a[title]') .forEach(function (el) { el.removeAttribute('title'); }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); });
Skip to Main Content