PageSourceSearch

https://www.made.com/scripts/Cookies.js?v=0.9.12.27336

js made.com collected 2026-10-01 12:00:54 UTC 5,952 bytes, 180 lines download raw bytes

1function createCookie(name, value, days, domain) {
2
3    if (days) {
4        var date = new Date();
5        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
6        var expires = "; expires=" + date.toGMTString();
7    }
8    else var expires = "";
9
10    var cookieValue = name + "=" + value + expires + "; path=/";
11
12    if (domain != undefined && domain != "") {
13        cookieValue += "; domain=" + domain;
14    }
15
16    // (Google Chrome) set the 'SameSite' attribute to nothing.    
17    // (Google Chrome) set the 'Secure' attribute if the protocol is https.
18    // Nb. samesite=none must include secure otherwise the cookie won't be allowed.
19    if (location.protocol == "https:") {
20        cookieValue += "; samesite=none; secure";
21    }
22
23    document.cookie = cookieValue;
24}
25
26function readCookie(name) {
27    
28    var nameEQ = name + "=";
29    var ca = document.cookie.split(';');
30    for (var i = 0; i < ca.length; i++) {
31        var c = ca[i];
32        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
33        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
34    }
35    return null;
36}
37
38function eraseCookie(name) {
39    createCookie(name, "", -1, "");
40}
41
42// Reads a cookie and splits on "&", returning the value for the keyName provided
43function readSplitCookie(cookieName, keyName) {
44    var cookieValue = {};
45    var nextSessionVariables = readCookie(cookieName);
46    if (nextSessionVariables != null) {
47        var splitVars = nextSessionVariables.split("&");
48        for (var i = 0; i < splitVars.length; i++) {
49            var splitKvp = splitVars[i].split("=");
50            if (splitKvp != null) {
51                cookieValue[splitKvp[0]] = splitKvp[1];
52            }
53        }
54    }
55    if (typeof (keyName) != 'undefined') {
56        return cookieValue[keyName];
57    }
58    return cookieValue;
59}
60
61// Sets a cookie - updating it with a key value pair
62function setSplitCookie(cookieName, keyName, keyValue, days) {
63 
64    var nextSessionVariables = readCookie(cookieName);
65    var newValue = "";
66    var valueAdded = false;
67
68    if (nextSessionVariables != null) {
69        var splitVars = nextSessionVariables.split("&");
70        for (var i = 0; i < splitVars.length; i++) {
71           // if (i > 0)
72                newValue += "&";
73            var splitKvp = splitVars[i].split("=");
74            if (splitKvp != null && splitKvp[0] == keyName) {
75                newValue += keyName + "=" + keyValue;
76                valueAdded = true;
77            }
78            else
79                newValue += splitVars[i];
80        }
81    }
82    if (!valueAdded)
83        newValue += "&" + keyName + "=" + keyValue;
84
85    if (newValue.indexOf("&") == 0) 
86        newValue = newValue.substring(1);
87
88    createCookie(cookieName, newValue, days, ABPlatformCookieDomain);
89}
90
91var nextCookie =
92{
93    set: function (name, value, days, seconds) {
94        var domain, date, expires, host;
95
96        var parsedSeconds = parseInt(seconds, 10);
97        if (isNaN(parsedSeconds)) {
98            if (days) {
99                date = new Date();
100                date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
101                expires = "; expires=" + date.toGMTString();
102            }
103            else {
104                expires = "";
105            }
106        } else {
107            var date = new Date();
108            var parsedDays = parseInt(days, 10);
109            if (!isNaN(parsedDays))
110                parsedSeconds += (parsedDays * 24 * 60 * 60);
111
112            date.setTime(date.getTime() + (parsedSeconds * 1000));
113            expires = "; expires=" + date.toGMTString();
114        }
115
116        host = window.location.host;
117
118        domain = nextCookie.getCookieDomain(host);
119
120        if (domain.length === 0) {
121            document.cookie = name + "=" + value + expires + "; path=/";
122        }
123        else {
124            document.cookie = name + "=" + value + expires + "; path=/; domain=" + domain;
125
126            // check if cookie was successfuly set to the given domain
127            // (otherwise it was a Top-Level Domain)
128            if (nextCookie.get(name) === null || nextCookie.get(name) !== value) {
129                // append "." to current domain
130                domain = '.' + host;
131                document.cookie = name + "=" + value + expires + "; path=/; domain=" + domain;
132            }
133        }
134    },
135
136    getCookieDomain: function (host) {
137        var domain, domainParts;
138
139        if (host.split('.').length === 1) {
140            // no "." in a domain - it's localhost or something similar
141            return "";
142        }
143        else {
144            // Remember the cookie on all subdomains.
145            //
146            // Start with trying to set cookie to the top domain.
147            // (example: if user is on foo.com, try to set
148            //  cookie to domain ".com")
149            //
150            // If the cookie will not be set, it means ".com"
151            // is a top level domain and we need to
152            // set the cookie to ".foo.com"
153            var prefixes = ["next", "nextdirect"];
154            domainParts = host.split('.');
155            if (prefixes.indexOf(domainParts[0].toLowerCase()) == -1) {
156                domainParts.shift();
157            }
158            domain = '.' + domainParts.join('.');
159        }
160        return domain;
161    },
162
163    get: function (name) {
164        var nameEQ = name + "=";
165        var ca = document.cookie.split(';');
166        for (var i = 0; i < ca.length; i++) {
167            var c = ca[i];
168            while (c.charAt(0) === ' ') {
169                c = c.substring(1, c.length);
170            }
171
172            if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
173        }
174        return null;
175    },
176
177    erase: function (name) {
178        nextCookie.set(name, '', -1);
179    }
180};

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.