block. */ (function () { 'use strict'; /* ============================ CONFIG ============================ */ var CONFIG = { geoEndpoint: 'https://busterspizza.com/api/geo', // returns {"country":"US"} targetCountry: 'US', targetOrigin: 'https://busterspizza.com', preservePath: true, // false = always link to the .com homepage position: 'bottom', shift) timeoutMs: 2500, dismissDays: 30, // 'bottom' or 'top' (fixed, no layout // how long a dismissal is remembered Page 7 of 11 text: "Looks like you're in the US. Visit Buster's Pizza USA for US locations and menu.", ctaLabel: 'Go to busterspizza.com', closeLabel: 'Stay on the Canadian site', brandColor: '#d62828', textColor: '#ffffff' }; /* ================================================================ */ var DISMISS_KEY = 'bp_geobanner_dismissed_until'; var COUNTRY_KEY = 'bp_geo_country'; /* ---------- 1. Crawler / bot check ---------- */ function isBot() { var ua = (navigator.userAgent || '').toLowerCase(); var botPattern = /googlebot|google-inspectiontool|adsbot google|mediapartners-google|apis-google|feedfetcher-google|storebot google|bingbot|bingpreview|duckduckbot|baiduspider|yandex|slurp|applebot|peta lbot|semrushbot|ahrefsbot|facebookexternalhit|twitterbot|linkedinbot|crawler| spider|bot\b|headlesschrome|lighthouse/; return botPattern.test(ua) || navigator.webdriver === true; } /* ---------- Safe storage helpers (private mode etc.) ---------- */ function getItem(store, key) { try { return window[store].getItem(key); } catch (e) { return null; } } function setItem(store, key, val) { try { window[store].setItem(key, val); } catch (e) { /* ignore */ } } function isDismissed() { var until = parseInt(getItem('localStorage', DISMISS_KEY), 10); return !isNaN(until) && Date.now() < until; } function rememberDismiss() { setItem('localStorage', DISMISS_KEY, String(Date.now() + CONFIG.dismissDays * 864e5)); } /* ---------- 2. Visitor location detection ---------- */ function getCountry(callback) { var cached = getItem('sessionStorage', COUNTRY_KEY); busterspizza.ca – Changes Required from Vendor B Page 8 of 11 if (cached) { callback(cached); return; } if (!window.fetch) { callback(null); return; } var controller = window.AbortController ? new AbortController() : null; var timer = setTimeout(function () { if (controller) controller.abort(); }, CONFIG.timeoutMs); fetch(CONFIG.geoEndpoint, { method: 'GET', credentials: 'omit', cache: 'no-store', signal: controller ? controller.signal : undefined }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (data) { clearTimeout(timer); var country = data && typeof data.country === 'string' ? data.country.toUpperCase() : null; if (country) setItem('sessionStorage', COUNTRY_KEY, country); callback(country); }) .catch(function () { clearTimeout(timer); callback(null); }); } /* ---------- 3. GeoBanner UI ---------- */ function targetUrl() { if (!CONFIG.preservePath) return CONFIG.targetOrigin + '/'; return CONFIG.targetOrigin + location.pathname + location.search; } function injectStyles() { var css = '#bp-geobanner{position:fixed;left:0;right:0;' + CONFIG.position + ':0;' + 'z-index:2147483000;background:' + CONFIG.brandColor + ';color:' + CONFIG.textColor + ';' + 'font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans serif;' + 'box-shadow:0 ' + (CONFIG.position === 'top' ? '2px' : '-2px') + ' 10px rgba(0,0,0,.2);' + 'transform:translateY(' + (CONFIG.position === 'top' ? '-100%' : busterspizza.ca – Changes Required from Vendor B Page 9 of 11 '100%') + ');transition:transform .3s ease}' + '#bp-geobanner.bp-show{transform:translateY(0)}' + '#bp-geobanner .bp-inner{max-width:1100px;margin:0 auto;padding:12px 16px;display:flex;' + 'flex-wrap:wrap;align-items:center;justify-content:center;gap:10px 16px;text-align:center}' + '#bp-geobanner .bp-cta{background:' + CONFIG.textColor + ';color:' + CONFIG.brandColor + ';' + 'padding:8px 16px;border-radius:4px;font-weight:700;text decoration:none;white-space:nowrap}' + '#bp-geobanner .bp-cta:hover,#bp-geobanner .bp-cta:focus{opacity:.9}' + '#bp-geobanner .bp-close{background:none;border:1px solid currentColor;color:inherit;' + 'padding:7px 14px;border-radius:4px;cursor:pointer;font:inherit;white space:nowrap}' + '@media (prefers-reduced-motion:reduce){#bp geobanner{transition:none}}'; var style = document.createElement('style'); style.id = 'bp-geobanner-style'; style.appendChild(document.createTextNode(css)); document.head.appendChild(style); } function showBanner() { if (document.getElementById('bp-geobanner')) return; injectStyles(); var banner = document.createElement('div'); banner.id = 'bp-geobanner'; banner.setAttribute('role', 'region'); banner.setAttribute('aria-label', 'Country site suggestion'); var inner = document.createElement('div'); inner.className = 'bp-inner'; var msg = document.createElement('span'); msg.textContent = CONFIG.text; var cta = document.createElement('a'); cta.className = 'bp-cta'; cta.href = targetUrl(); cta.hreflang = 'en-US'; cta.rel = 'alternate'; busterspizza.ca – Changes Required from Vendor B Page 10 of 11 cta.textContent = CONFIG.ctaLabel; var close = document.createElement('button'); close.type = 'button'; close.className = 'bp-close'; close.textContent = CONFIG.closeLabel; close.addEventListener('click', function () { rememberDismiss(); banner.classList.remove('bp-show'); setTimeout(function () { banner.remove(); }, 350); }); inner.appendChild(msg); inner.appendChild(cta); inner.appendChild(close); banner.appendChild(inner); document.body.appendChild(banner); requestAnimationFrame(function () { banner.classList.add('bp-show'); }); } /* ---------- Run ---------- */ function init() { if (isBot() || isDismissed()) return; getCountry(function (country) { if (country === CONFIG.targetCountry) showBanner(); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();