1;(function () { 2 var thisScript = document.currentScript 3 var shopId = thisScript.dataset.shopId 4 var url = thisScript.dataset.url 5 var key = thisScript.dataset.key 6 var siteSection = thisScript.dataset.siteSection 7 var timestamp = thisScript.dataset.timestamp 8 let { hostname, pathname } = location 9 let { title, referrer } = document 10 var tabId = getTabId() 11 window.qbTabId = tabId 12 13 window.addEventListener( 14 'load', 15 function () { 16 send() 17 }, 18 false 19 ) 20 21 window.addEventListener( 22 'beforeunload', 23 function () { 24 send(true) 25 }, 26 false 27 ) 28 29 function send(close = false) { 30 const params = { 31 closed: close, 32 tab_id: tabId, 33 shop_id: shopId, 34 hostname, 35 pathname: pathname || '/', 36 title, 37 site_section: siteSection, 38 referrer: referrer.indexOf(hostname) < 0 ? referrer : '', 39 key, 40 } 41 if (timestamp) params.timestamp = timestamp 42 fetch(`${url}?` + new URLSearchParams(params)) 43 } 44 45 function getTabId() { 46 var tabId = sessionStorage.getItem('qbTabId') 47 48 if (!tabId) { 49 tabId = generateRandomId(16) 50 sessionStorage.setItem('qbTabId', tabId) 51 } 52 53 return tabId 54 } 55 56 function generateRandomId(length) { 57 const characters = 58 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' 59 let id = '' 60 61 for (let i = 0; i < length; i++) { 62 const randomIndex = Math.floor(Math.random() * characters.length) 63 id += characters.charAt(randomIndex) 64 } 65 66 return id 67 } 68})()
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.