1function doNotTrackMe() 2{ 3 if (window.doNotTrack 4 || navigator.doNotTrack 5 || navigator.msDoNotTrack 6 || (typeof window.external !== "undefined" && 'msTrackingProtectionEnabled' in window.external) 7 ) { 8 if (window.doNotTrack == "1" 9 || navigator.doNotTrack == "yes" 10 || navigator.doNotTrack == "1" 11 || navigator.msDoNotTrack == "1" 12 || (typeof window.external.msTrackingProtectionEnabled === "function" && window.external.msTrackingProtectionEnabled()) 13 ) { 14 return true; //enabled 15 } else { 16 return false;//disabled 17 } 18 } else { 19 return false;//not supported 20 } 21} 22if (typeof is_ajax_data === 'undefined') { 23 var is_ajax_data = {}; 24} 25if (typeof is_checkout_found === 'undefined') { 26 var is_checkout_found = 0; 27} 28 29$(document).ready(function() { 30 //interaction event 31 $('a, button').on("click",function(event){ 32 secure_ssl = ' Secure;'; 33 if (location.protocol !== 'https:') { 34 secure_ssl = ''; 35 } 36 document.cookie = "sm_i=1; path=/; SameSite=Lax;"+secure_ssl; 37 }); 38 39 if(window.location.search.includes('fbclid=')) { 40 let fbc = document.cookie.split(';').filter(c => c.includes('_fbc=')).map(c => c.split('_fbc=')[1]); 41 fbc = (fbc.length && fbc[0]) || ''; 42 if (fbc == '') { 43 fbc = 'fb.1.'+ (+new Date()) +'.'+ window.location.search.split('fbclid=')[1]; 44 //save fbc cookie 45 secure_ssl = ' Secure;'; 46 if (location.protocol !== 'https:') { 47 secure_ssl = ''; 48 } 49 domain = (function() { 50 var i=0,domain=document.domain,p=domain.split('.'),s='_gd'+(new Date()).getTime(); 51 while(i<(p.length-1) && document.cookie.indexOf(s+'='+s)==-1){ 52 domain = p.slice(-1-(++i)).join('.'); 53 document.cookie = s+"="+s+";domain="+domain+";"; 54 } 55 document.cookie = s+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain="+domain+";"; 56 return domain; 57 })(); 58 document.cookie = "_fbc="+fbc+"; domain = ."+domain+"; path=/; SameSite=Lax;"+secure_ssl; 59 } 60 } 61 62 //api custom consents ONLY OC4 63 const api_consents = document.querySelectorAll('#is-api-consents input'); 64 api_consents.forEach(function (element) { 65 element.addEventListener('change', (event) => { 66 sm_custom_consents(api_consents); 67 }); 68 }); 69 70 is_ajax_data.url = window.location.href; 71 $.ajax({ 72 async: true, 73 cache: false, 74 type: 'post', 75 url: 'index.php?route=extension/analytics/script_manager/ajaxScripts&v='+(new Date()).getTime()+"&title="+encodeURIComponent(document.title), 76 dataType: 'json', 77 data: is_ajax_data, 78 success: function(result) { 79 if ((typeof doNotTrackMe !== "function" || !doNotTrackMe())) { 80 var i; 81 if (result !== null) { 82 for (i = 0; i < result.length; i++) { 83 if (result[i] != '') { 84 (new Function(result[i]))(); 85 } 86 } 87 } 88 } 89 }, 90 error: function (request, status, error) { 91 console.log(request.responseText); 92 } 93 }); 94}); 95 96$(window).on('load', function() { 97 //support for checkout extensions 98 $(document).one("ajaxStop", function() { 99 if (is_checkout_found == 0) {//not set yet 100 document.querySelectorAll('input[type="radio"][name="payment_method"],input[type="radio"][name="shipping_method"]').forEach((input) => { 101 is_checkout_found = 1;//use radio boxes 102 input.addEventListener('click', (e)=>{ 103 type = ""; 104 if (e.target.name == "payment_method") { 105 type = "payment"; 106 } else if (e.target.name == "shipping_method") { 107 type = "shipping"; 108 } 109 $.ajax({ 110 async: true, 111 cache: false, 112 type: 'get', 113 url: 'index.php?route=extension/analytics/script_manager/ajaxSuccess&v='+(new Date()).getTime(), 114 data: "&"+e.target.name+"="+e.target.value+"&type="+type+"&url="+encodeURIComponent(window.location.href), 115 dataType: 'json', 116 success: function(result) { 117 if ((typeof doNotTrackMe !== "function" || !doNotTrackMe()) && result !== null && result != '') { 118 (new Function(result))() 119 } 120 }, 121 error: function (request, status, error) { 122 console.log(request.responseText); 123 } 124 }); 125 }); 126 }); 127 } 128 // if the confirm button is added by java 129 if (is_ajax_data.checkout != '' && is_ajax_data.page == 'checkout') { 130 findConfirmButton(); 131 $(document).ajaxSuccess(function( event, jqxhr, settings ) { 132 findConfirmButton(); 133 }); 134 } 135 }); 136}); 137 138function findConfirmButton() 139{ 140 $(is_ajax_data.checkout).one('click', function () { 141 is_ajax_data.page = "purchase"; 142 is_ajax_data.order_id = Date.now()+'-'+Math.floor(Math.random() * 999999999); 143 $.ajax({ 144 async: false, 145 cache: false, 146 type: 'post', 147 url: 'index.php?route=extension/analytics/script_manager/ajaxScripts&v='+(new Date()).getTime()+"&title="+encodeURIComponent(document.title), 148 dataType: 'json', 149 data: is_ajax_data, 150 success: function(result) { 151 if ((typeof doNotTrackMe !== "function" || !doNotTrackMe())) { 152 var i; 153 if (result !== null) { 154 for (i = 0; i < result.length; i++) { 155 if (result[i] != '') { 156 (new Function(result[i]))() 157 } 158 } 159 } 160 } 161 }, 162 error: function (request, status, error) { 163 console.log(request.responseText); 164 } 165 }); 166 }); 167} 168 169$(document).ajaxSuccess(function( event, jqxhr, settings ) { 170 if (typeof jqxhr.responseText !== 'undefined' && jqxhr.responseText !== null && jqxhr.responseText !== '') { 171 try { 172 if (typeof JSON.parse(jqxhr.responseText).error !== 'undefined') { 173 return; 174 } 175 } catch (e) {} 176 if (typeof settings !== 'undefined' && typeof settings.url !== 'undefined' && typeof settings.data !== 'undefined') { 177 type = null; 178 if (settings.url.includes("/cart.add") || settings.url.includes("/cart/add") || settings.url.includes("/cart|add") || settings.url.includes("/add_to_cart")) { 179 type = 'cartadd'; 180 } else if (settings.url.includes("/cart.edit") || settings.url.includes("/cart/edit") || settings.url.includes("/cart|edit")) { 181 type = 'cartedit'; 182 } else if (settings.url.includes("/cart.remove") || settings.url.includes("/cart/remove") || settings.url.includes("/cart|remove")) { 183 type = 'cartremove'; 184 } else if (settings.url.includes("/wishlist.add") || settings.url.includes("/wishlist/add") || settings.url.includes("/wishlist|add")) { 185 type = 'wishlist'; 186 } else if (settings.url.includes("/compare.add") || settings.url.includes("/compare/add") || settings.url.includes("/compare|add")) { 187 type = 'compare'; 188 }
188 else if (is_checkout_found != 1 && !settings.url.includes("onepagecheckout") && !settings.url.includes("submit")) {// exclude onepagecheckout (payment_method/savepayment), journal3 (journal3/checkout/save) 189 if (settings.url.includes("/shipping_method.save") || settings.url.includes("/shipping_method|save")) { 190 is_checkout_found = 2;//use ajax success 191 //OC4 ONLY - Executing Ajax causes confirmation errors 192 urlParams = new URLSearchParams(settings.data); 193 content_name = "shipping"; 194 if (urlParams.has('shipping_method')) { 195 content_name = urlParams.get('shipping_method'); 196 } 197 if (is_cmethod !== null) { 198 for (i = 0; i < is_cmethod["shipping_method"].length; i++) { 199 if (is_cmethod["shipping_method"][i] != '') { 200 (new Function(is_cmethod["shipping_method"][i].replace('#shipping#',content_name)))() 201 } 202 } 203 } 204 } else if (settings.url.includes("/payment_method.save") || settings.url.includes("/payment_method|save")) {//causes order confirm error 205 is_checkout_found = 2;//use ajax success 206 //OC4 ONLY - Executing Ajax causes confirmation errors 207 urlParams = new URLSearchParams(settings.data); 208 content_name = "payment"; 209 if (urlParams.has('payment_method')) { 210 content_name = urlParams.get('payment_method'); 211 } 212 if (is_cmethod !== null) { 213 for (i = 0; i < is_cmethod["payment_method"].length; i++) { 214 if (is_cmethod["payment_method"][i] != '') { 215 (new Function(is_cmethod["payment_method"][i].replace('#payment#',content_name)))() 216 } 217 } 218 } 219 } else if (settings.url.includes("/shipping_method/save") || settings.url.includes("/shipping_method/validate")) { 220 is_checkout_found = 2;//use ajax success 221 //OC3,OC2,OC1 ONLY 222 type = "shipping"; 223 } else if (settings.url.includes("/payment_method/save") || settings.url.includes("/payment_method/validate")) { 224 is_checkout_found = 2;//use ajax success 225 //OC3,OC2,OC1 ONLY 226 type = "payment"; 227 } 228 } else if (settings.url.includes("/superquickcheckout/submit") || settings.url.includes("/superquickcheckout.submit") || settings.url.includes("/superquickcheckout|submit") || settings.url.includes("/buyoneclick/submit") || settings.url.includes("/buyoneclick.submit") || settings.url.includes("/buyoneclick|submit")) {//module support 229 type = "purchase"; 230 } 231 if (type != null) { 232 $.ajax({ 233 async: true, 234 cache: false, 235 type: 'get', 236 url: 'index.php?route=extension/analytics/script_manager/ajaxSuccess&v='+(new Date()).getTime(), 237 data: settings.data+"&type="+type+"&url="+encodeURIComponent(window.location.href), 238 dataType: 'json', 239 success: function(result) { 240 if ((typeof doNotTrackMe !== "function" || !doNotTrackMe()) && result !== null && result != '') { 241 (new Function(result))() 242 } 243 } 244 }); 245 } 246 } 247 } 248}); 249 250function sm_consent(accept, suffix, duration) { 251 $('#ism-consent-box').fadeOut(400); 252 $('#ism-consent-modal').fadeOut(400); 253 var now = new Date(); 254 now.setTime(now.getTime()+duration*86400000); 255 secure_ssl = ' Secure;'; 256 if (location.protocol !== 'https:') { 257 secure_ssl = ''; 258 } 259 document.cookie = 'sm_consent_analytics'+suffix+'='+accept[0]+'; expires='+now.toUTCString()+'; path=/; domain=.'+document.domain+'; SameSite=Lax;'+secure_ssl; 260 document.cookie = 'sm_consent_marketing'+suffix+'='+accept[1]+'; expires='+now.toUTCString()+'; path=/; domain=.'+document.domain+'; SameSite=Lax;'+secure_ssl; 261 document.cookie = 'sm_consent_privacy'+suffix+'='+accept[2]+'; expires='+now.toUTCString()+'; path=/; domain=.'+document.domain+'; SameSite=Lax;'+secure_ssl; 262 263 // run script 264 is_ajax_data.url = window.location.href; 265 $.ajax({ 266 async: true, 267 cache: false, 268 type: 'post', 269 url: 'index.php?route=extension/analytics/script_manager/ajaxScripts&v='+(new Date()).getTime()+"&title="+encodeURIComponent(document.title), 270 dataType: 'json', 271 data: is_ajax_data, 272 success: function(result) { 273 if ((typeof doNotTrackMe !== "function" || !doNotTrackMe())) { 274 var i; 275 if (result !== null) { 276 for (i = 0; i < result.length; i++) { 277 if (result[i] != '') { 278 (new Function(result[i]))(); 279 } 280 } 281 } 282 } 283 }, 284 error: function (request, status, error) { 285 console.log(request.responseText); 286 } 287 }); 288} 289 290function sm_has_consent(consent_add, consent_require, cookie_suffix
290) { 291 var cookie_consent_analytics = isGetCookie('sm_consent_analytics'+cookie_suffix); 292 var cookie_consent_marketing = isGetCookie('sm_consent_marketing'+cookie_suffix); 293 var cookie_consent_privacy = isGetCookie('sm_consent_privacy'+cookie_suffix); 294 295 if (cookie_consent_analytics == '' || cookie_consent_marketing == ''|| cookie_consent_privacy == '') { // not set 296 if (!consent_add || !consent_require) {//cookie not needed 297 return [['0', 0].includes(cookie_consent_analytics) ? 0 : 2, ['0', 0].includes(cookie_consent_marketing) ? 0 : 2, ['0', 0].includes(cookie_consent_privacy) ? 0 : 2]; 298 } 299 return [0, 0, 0];//cookie needed 300 } 301 cookie_consent_analytics = ['0', 0].includes(cookie_consent_analytics) ? 0 : 1; 302 cookie_consent_marketing = ['0', 0].includes(cookie_consent_marketing) ? 0 : 1; 303 cookie_consent_privacy = ['0', 0].includes(cookie_consent_privacy) ? 0 : 1; 304 305 return [cookie_consent_analytics, cookie_consent_marketing, cookie_consent_privacy]; 306} 307 308function sm_custom_consents(api_consents) { 309 consents = {}; 310 api_consents.forEach(function (consent) { 311 var is_checked = 0; 312 var is_name = consent.attributes.name.value; 313 if (consent.checked) { 314 is_checked = 1; 315 } 316 consents[is_name]=is_checked; 317 }); 318 secure_ssl = ' Secure;'; 319 if (location.protocol !== 'https:') { 320 secure_ssl = ''; 321 } 322 document.cookie = "sm_api_consents="+JSON.stringify(consents)+"; path=/; SameSite=Lax;"+secure_ssl; 323} 324 325function sm_clear_cookies(cookieList) { 326 const allCookies = document.cookie.split(';'); 327 const domain = window.location.hostname; 328 const path = '/'; 329 cookieList.forEach((cookieName) => { 330 const isWildcard = cookieName.includes('*'); 331 const regexPattern = '^' + cookieName.split('*').join('.*') + '$'; 332 const regex = new RegExp(regexPattern);
333 allCookies.forEach((cookie) => { 334 const cookieKey = cookie.split('=')[0].trim(); 335 if ((isWildcard && regex.test(cookieKey)) || cookieKey === cookieName) { 336 // Delete cookie from the top domain 337 document.cookie = cookieKey + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=' + path + '; domain=' + domain + ';'; 338 // Delete cookie from subdomains 339 const subDomains = domain.split('.'); 340 for(let i = 1; i < subDomains.length - 1; i++) { 341 const subDomain = subDomains.slice(i).join('.'); 342 document.cookie = cookieKey + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=' + path + '; domain=' + subDomain + ';'; 343 } 344 } 345 }); 346 }); 347} 348 349function isGetCookie(cname) { 350 let name = cname + "="; 351 let decodedCookie = decodeURIComponent(document.cookie); 352 let ca = decodedCookie.split(';'); 353 for(let i = 0; i <ca.length; i++) { 354 let c = ca[i]; 355 while (c.charAt(0) == ' ') { 356 c = c.substring(1); 357 } 358 if (c.indexOf(name) == 0) { 359 return c.substring(name.length, c.length); 360 } 361 } 362 return ""; 363}
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.