1/** 2 * block js set cookies 3 * 4 * @var ct-ultimate-gdpr-cookie-block.blocked - via wp_localize_script 5 * 6 **/ 7 8if (ct_ultimate_gdpr_cookie_block && ct_ultimate_gdpr_cookie_block.blocked) { 9 10 function ct_should_block_cookie(cookiename) { 11 if ( 12 !!1 13 && cookiename !== 'ct-ultimate-gdpr-cookie' 14 && cookiename !== 'ct-ultimate-gdpr-age' 15 && (ct_ultimate_gdpr_cookie_block.level < 2 || ct_ultimate_gdpr_cookie_block.blocked.indexOf(cookiename) !== -1)) { 16 return true; 17 } 18 19 return false; 20 } 21 22 try { 23 24 var ct_ultimate_gdpr_cookie_setter_original = document.__lookupSetter__("cookie"); 25 var ct_ultimate_gdpr_cookie_getter_original = document.__lookupGetter__("cookie"); 26 var old_cookie = document.cookie; 27 28 Object.defineProperty(document, 'cookie', { 29 30 get: function () { 31 return (ct_ultimate_gdpr_cookie_getter_original && ct_ultimate_gdpr_cookie_getter_original.apply(document)) ? 32 ct_ultimate_gdpr_cookie_getter_original.apply(document) : this._value; 33 }, 34 set: function (val) { 35 36 if (val && (val.toLowerCase().indexOf('expires=') >= 0 || val.toLowerCase().indexOf('path=') >= 0 || val.indexOf(';') === -1)) { 37 38 // single cookie with or without an expires parameter 39 var parts = val.split(';'); 40 if(parts[0]){ 41 var name = parts[0].split('=')[0]; 42 var value = parts[0].split('=')[1]; 43 44 if (ct_should_block_cookie(name)) { 45 return; 46 } 47 } 48 49 } else if (val) { 50 51 // multiple cookies 52 parts = val.split(';'); 53 var cookievalue = ''; 54 for (var i in parts) { 55 //some cases have values such as "dc=tld;domain=.wpengine.com;" causing the split to have an extra index 56 if(parts[i]){ 57 name = parts[i].split('=')[0].trim(); 58 value = parts[i].split('=')[1].trim(); 59 60 if (!ct_should_block_cookie(name)) { 61 if (cookievalue.length) { 62 cookievalue += '; '; 63 } 64 cookievalue += name + "=" + value; 65 } 66 } 67 } 68 69 val = cookievalue; 70 71 } 72 73 this._value = val; 74 ct_ultimate_gdpr_cookie_setter_original && ct_ultimate_gdpr_cookie_setter_original.apply(document, arguments) 75 76 }, 77 configurable: true 78 }); 79 80 document.cookie = old_cookie; 81 82 } catch (e) { 83 // console.log(e); 84 } 85 86}
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.