/* Баннер ЧП 2026: сегмент GetCourse + пауза в браузере на 48 часов. */ (function () { 'use strict'; if (window.top !== window.self) return; if (window.GCBF26Banner && window.GCBF26Banner.version === 'local48-v2') return; if (window.GCBF26Banner && typeof window.GCBF26Banner.destroy === 'function') window.GCBF26Banner.destroy(); const cfg = Object.assign({ enabled: true, statePath: '/bf26-banner-check', pathPrefixes: [], desktopImage: 'https://fs.getcourse.ru/fileservice/file/download/a/35905/sc/292/h/bca224ab908ce9447df673bc6246dd6c.png', mobileImage: 'https://fs.getcourse.ru/fileservice/file/download/a/35905/sc/239/h/98aedd0ffadcb600ab191e6982608820.png', href: 'https://lunegova.ru/black26?utm_source=lk&utm_medium=chp26&utm_campaign=allpage&utm_term=presale' }, window.GCBF26BannerConfig || {}); const gate = new URL(cfg.statePath, location.origin); if (!cfg.enabled || gate.origin !== location.origin) return; if (location.pathname.replace(/\/$/, '') === gate.pathname.replace(/\/$/, '')) return; if (/\/(edit|update)(\/|$)/.test(location.pathname)) return; if (cfg.pathPrefixes.length && !cfg.pathPrefixes.some(p => location.pathname.startsWith(p))) return; const KEY = 'lunegova_bf26_hidden_until_v2'; const PERIOD = 48 * 60 * 60 * 1000; let root = null, stopped = false, refreshing = null, interval = null, wake = null; let memoryUntil = 0; function readUntil() { let local = 0, cookie = 0; try { local = Number(localStorage.getItem(KEY)) || 0; } catch (_) {} try { const match = document.cookie.split('; ').find(s => s.startsWith(KEY + '=')); if (match) cookie = Number(decodeURIComponent(match.slice(KEY.length + 1))) || 0; } catch (_) {} return Math.max(...[local, cookie, memoryUntil].filter(n => Number.isSafeInteger(n) && n >= 0)); } function savePause() { const until = Date.now() + PERIOD; memoryUntil = until; try { localStorage.setItem(KEY, String(until)); } catch (_) { try { document.cookie = KEY + '=' + until + '; Max-Age=172800; Path=/; SameSite=Lax' + (location.protocol === 'https:' ? '; Secure' : ''); } catch (_) {} } armWake(until); } function armWake(until) { clearTimeout(wake); if (until > Date.now()) wake = setTimeout(refresh, Math.min(until - Date.now() + 100, 2147483647)); } function hide() { if (root) root.remove(); root = null; } function dismiss() { savePause(); hide(); } function blockVisible(node, doc) { if (!node) return false; for (let el = node; el && el.nodeType === 1; el = el.parentElement) { const style = doc.defaultView.getComputedStyle(el); if (el.hidden || style.display === 'none' || style.visibility === 'hidden' || style.visibility === 'collapse' || style.contentVisibility === 'hidden' || Number(style.opacity) === 0) return false; } return true; } function inSegment() { return new Promise(resolve => { const frame = document.createElement('iframe'); frame.title = 'Проверка сегмента баннера'; frame.tabIndex = -1; frame.setAttribute('aria-hidden', 'true'); Object.assign(frame.style, { position: 'fixed', left: '-100000px', top: '0', border: '0', opacity: '0', pointerEvents: 'none', width: Math.max(320, window.innerWidth) + 'px', height: '800px' }); let ended = false; const finish = allowed => { if (ended) return; ended = true; clearTimeout(timeout); frame.remove(); resolve(allowed); }; const timeout = setTimeout(() => finish(false), 8000); frame.onerror = () => finish(false); frame.onload = () => setTimeout(() => { if (ended) return; try { const doc = frame.contentDocument; const current = new URL(frame.contentWindow.location.href); const marker = doc && doc.querySelector('.gc-bf26-eligible'); finish(current.origin === gate.origin && current.pathname.replace(/\/$/, '') === gate.pathname.replace(/\/$/, '') && !!marker && blockVisible(marker, doc) && /\bBF26_ALLOWED\b/.test(marker.textContent)); } catch (_) { finish(false); } }, 200); const url = new URL(gate); url.searchParams.set('_bf26', Date.now() + '-' + Math.random().toString(36).slice(2)); frame.src = url.href; document.body.appendChild(frame); }); } function render() { if (root || stopped) return; if (!document.getElementById('gc-bf26-style')) { const style = document.createElement('style'); style.id = 'gc-bf26-style'; style.textContent = ` #gc-bf26-banner{position:fixed;left:90px;bottom:22px;width:340px;max-width:calc(100vw - 110px);z-index:100050;box-sizing:border-box} #gc-bf26-banner *{box-sizing:border-box} #gc-bf26-banner .gc-bf26-link{display:block;overflow:hidden;border-radius:18px;box-shadow:0 8px 30px #0005;line-height:0;background:#111} #gc-bf26-banner picture{display:block} #gc-bf26-banner img{display:block;width:100%;height:auto;margin:0;border:0} #gc-bf26-banner .gc-bf26-close{position:absolute;right:2px;top:2px;z-index:2;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:transparent;color:#fff;cursor:pointer} #gc-bf26-banner .gc-bf26-close::before{content:"";position:absolute;inset:8px;background:#0009;border-radius:50%} #gc-bf26-banner .gc-bf26-close svg{position:relative;width:19px;height:19px;pointer-events:none} #gc-bf26-banner .gc-bf26-close:hover::before{background:#111e} #gc-bf26-banner a:focus-visible,#gc-bf26-banner button:focus-visible{outline:3px solid #e8ff60;outline-offset:3px} @media(max-width:767px){#gc-bf26-banner{left:12px;bottom:calc(76px + env(safe-area-inset-bottom,0px));width:280px;max-width:calc(100vw - 24px)}#gc-bf26-banner .gc-bf26-link{border-radius:14px}} `; document.head.appendChild(style); } root = document.createElement('aside'); root.id = 'gc-bf26-banner'; root.setAttribute('aria-label', 'Предпродажа Чёрной пятницы'); root.innerHTML = 'Не ставь прогресс на паузу. Предпродажа Чёрной пятницы'; const link = root.querySelector('a'); link.href = cfg.href; root.querySelector('source').srcset = cfg.mobileImage; root.querySelector('img').src = cfg.desktopImage; root.querySelector('img').addEventListener('error', hide); const onLink = () => { savePause(); setTimeout(hide, 0); }; link.addEventListener('click', onLink); link.addEventListener('auxclick', event => { if (event.button === 1) onLink(); }); root.querySelector('button').addEventListener('click', event => { event.preventDefault(); event.stopPropagation(); dismiss(); }); document.body.appendChild(root); } function refresh() { if (stopped) return Promise.resolve(); const until = readUntil(); if (until > Date.now()) { hide(); armWake(until); return Promise.resolve(); } if (document.visibilityState === 'hidden') return Promise.resolve(); if (refreshing) return refreshing; refreshing = inSegment().then(allowed => { if (stopped) return; const latest = readUntil(); if (!allowed || latest > Date.now()) { hide(); armWake(latest); return; } render(); }).finally(() => { refreshing = null; }); return refreshing; } function onStorage(event) { if (event.key === KEY || event.key === null) refresh(); } function reset() { memoryUntil = 0; try { localStorage.removeItem(KEY); } catch (_) {} try { document.cookie = KEY + '=; Max-Age=0; Path=/; SameSite=Lax'; } catch (_) {} clearTimeout(wake); return refresh(); } function destroy() { stopped = true; clearInterval(interval); clearTimeout(wake); hide(); window.removeEventListener('focus', refresh); window.removeEventListener('pageshow', refresh); window.removeEventListener('storage', onStorage); document.removeEventListener('visibilitychange', refresh); const style = document.getElementById('gc-bf26-style'); if (style) style.remove(); } window.GCBF26Banner = { version: 'local48-v2', refresh, reset, destroy }; function start() { if (stopped) return; refresh(); interval = setInterval(() => { if (root) refresh(); }, 120000); window.addEventListener('focus', refresh); window.addEventListener('pageshow', refresh); window.addEventListener('storage', onStorage); document.addEventListener('visibilitychange', refresh); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start, { once: true }); else start(); })();