1(function () { 2 var keys = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term', 'roistat', 'yclid', 'gclid', 'fbclid']; 3 4 function readCookie(name) { 5 var parts = document.cookie ? document.cookie.split('; ') : []; 6 for (var i = 0; i < parts.length; i++) { 7 var item = parts[i].split('='); 8 if (item.shift() === name) { 9 return decodeURIComponent(item.join('=')); 10 } 11 } 12 return ''; 13 } 14 15 function writeCookie(name, value) { 16 var maxAge = 60 * 60 * 24 * 90; 17 document.cookie = name + '=' + encodeURIComponent(value) + '; path=/; max-age=' + maxAge + '; SameSite=Lax'; 18 } 19 20 function getStored(key) { 21 var value = ''; 22 try { 23 value = localStorage.getItem('dp_' + key) || ''; 24 } catch (e) {} 25 26 return value || readCookie('dp_' + key); 27 } 28 29 function setStored(key, value) { 30 if (!value) { 31 return; 32 } 33 34 try { 35 localStorage.setItem('dp_' + key, value); 36 } catch (e) {} 37 38 writeCookie('dp_' + key, value); 39 } 40 41 function collectFromUrl() { 42 var params = new URLSearchParams(window.location.search || ''); 43 keys.forEach(function (key) { 44 var value = params.get(key); 45 if (value) { 46 setStored(key, value); 47 } 48 }); 49 } 50 51 function fillUtmFields(root) { 52 root = root || document; 53 keys.forEach(function (key) { 54 var value = getStored(key); 55 if (!value) { 56 return; 57 } 58 59 root.querySelectorAll('input[data-utm-field="' + key + '"]').forEach(function (input) { 60 if (!input.value) { 61 input.value = value; 62 } 63 }); 64 }); 65 } 66 67 collectFromUrl(); 68 69 if (document.readyState === 'loading') { 70 document.addEventListener('DOMContentLoaded', function () { 71 fillUtmFields(document); 72 }); 73 } else { 74 fillUtmFields(document); 75 } 76 77 document.addEventListener('submit', function (event) { 78 fillUtmFields(event.target); 79 }, true); 80})();
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.