1(() => { 2 const LOADER_SRC = 'https://whitelabels.stickeebroadband.co.uk/js/loader.js'; 3 const DEBUG = new URLSearchParams(window.location.search).has('debugWidget'); 4 const STATE_KEY = '__BS_STICKEE_LOADER_STATE__'; 5 6 const state = window[STATE_KEY] || (window[STATE_KEY] = { 7 promise: null, 8 ready: false 9 }); 10 11 const debugLog = (...args) => { 12 if (!DEBUG) return; 13 console.info('[BS widget]', ...args); 14 }; 15 16 function findExistingScript() { 17 return Array.from(document.scripts).find((script) => script.src === LOADER_SRC) || null; 18 } 19 20 function ensureLoaderScript() { 21 if (state.ready) return Promise.resolve(); 22 if (state.promise) return state.promise; 23 24 state.promise = new Promise((resolve, reject) => { 25 const existing = findExistingScript(); 26 if (existing) { 27 if (existing.dataset.bsReady === '1') { 28 state.ready = true; 29 debugLog('loader ready'); 30 resolve(); 31 return; 32 } 33 existing.addEventListener('load', () => { 34 state.ready = true; 35 existing.dataset.bsReady = '1'; 36 debugLog('loader ready'); 37 resolve(); 38 }, { once: true }); 39 existing.addEventListener('error', () => { 40 debugLog('loader error'); 41 state.promise = null; 42 reject(new Error('Stickee loader failed to load.')); 43 }, { once: true }); 44 return; 45 } 46 47 const script = document.createElement('script'); 48 script.src = LOADER_SRC; 49 script.async = true; 50 script.dataset.bsInjected = '1'; 51 script.addEventListener('load', () => { 52 state.ready = true; 53 script.dataset.bsReady = '1'; 54 debugLog('loader ready'); 55 resolve(); 56 }, { once: true }); 57 script.addEventListener('error', () => { 58 debugLog('loader error'); 59 state.promise = null; 60 reject(new Error('Stickee loader failed to load.')); 61 }, { once: true }); 62 document.head.appendChild(script); 63 }); 64 65 return state.promise; 66 } 67 68 function ensure(options = {}) { 69 const timeoutMs = Number(options.timeoutMs) > 0 ? Number(options.timeoutMs) : 12000; 70 return Promise.race([ 71 ensureLoaderScript(), 72 new Promise((_, reject) => { 73 setTimeout(() => reject(new Error(`Stickee loader timed out after ${timeoutMs}ms.`)), timeoutMs); 74 }) 75 ]); 76 } 77 78 function prewarm(reason = 'unknown') { 79 debugLog(`prewarm requested: ${reason}`); 80 ensure({ timeoutMs: 12000 }).catch((error) => { 81 debugLog(`prewarm failed: ${error.message}`); 82 }); 83 } 84 85 window.BSStickeeLoader = { 86 ensure, 87 prewarm, 88 isReady: () => Boolean(state.ready) 89 }; 90})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.