PageSourceSearch

https://www.restplass.no/static/js/cm-head.js?1676647551

js restplass.no collected 2026-09-25 03:10:31 UTC 6,610 bytes, 154 lines download raw bytes

1var CM_cookieManager = (function() {
2    // set activeForAll to true if you want to activate consent management for all visitors regardless of geolocation
3    // if activeForAll is fakse than consent management is only active for EU locations
4    const activeForAll = true;
5    // if you really really need session cookie
6    const ignoredCookies = ['rg_features', 'CM_cookieConsent'];
7    var _isIgnoredCookie = function(c) {
8        for (i=0;  i < ignoredCookies.length; i++) {
9           if (c.indexOf(ignoredCookies[i]) !== -1) return true;
10        }
11        return false;
12    }
13
14    var gdprZone = false;
15    var intervalId = -1;
16    var removedCookies = new Array();
17
18    var killCookies = function () {
19        var killCount = 0;
20        var lastCookiePropLength = document.cookie.length;
21        // nothing to kill
22        if (lastCookiePropLength === 0) return killCount;
23
24        document.cookie.split(";").forEach(function(c) {
25            // skip removal if cookie is session cookie
26            if (_isIgnoredCookie(c)) return;
27
28            var kuki = c.replace(/^ +/, "");
29
30            var removeCookie = function (s) {
31                document.cookie = kuki.replace(/=.*/, "=" + sufix + ";expires=" + new Date().toUTCString());
32                if (document.cookie.length < lastCookiePropLength) {
33                    // successfully removed cookie
34                    lastCookiePropLength = document.cookie.length;
35                    removedCookies.push(kuki + s);
36                    //console.log(kuki + sufix);
37                    killCount++;
38                    return true;
39                }
40                return false;
41            }
42
43            var sufix = ";path=/";
44            if (removeCookie(sufix) == true) return;
45
46            var sufix = ";domain=." + location.host + ";path=/";
47            if (removeCookie(sufix) == true) return;
48
49            var sufix = ";domain=." + location.host.split(':')[0].split('.').slice(-2).join(".") + ";path=/";
50            if (removeCookie(sufix) == true) return;
51
52            //console.log('Couldn\'t kill cookie: ' + kuki);
53        });
54
55        //console.log('Removed: ' + killCount + ' cookie(s)');
56        return killCount;
57    }
58
59    return {
60        start: function () {
61            if (document.cookie.indexOf('CM_cookieConsent=1') === -1) {
62                var janOffset = new Date(new Date().getFullYear(), 0, 1).getTimezoneOffset();
63                var julOffset = new Date(new Date().getFullYear(), 6, 1).getTimezoneOffset();
64
65                // almost only EU countries in 0, +1 and +2 have DST
66                if ((janOffset >= -120 && janOffset <= 0 && julOffset < janOffset) || activeForAll === true) {
67                    gdprZone = true;
68                    // make sure no cookies before me
69                    // console.log("Killing cookies");
70                    killCookies();
71                    var cookieDesc = Object.getOwnPropertyDescriptor(Document.prototype, 'cookie') ||
72                                    Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');
73                    if (cookieDesc && cookieDesc.configurable) {
74                        Object.defineProperty(document, 'cookie', {
75                            get: function () {
76                                return cookieDesc.get.call(document);
77                            },
78                            set: function (val) {
79                                if (val.indexOf('CM_cookieConsent') !== -1 || document.cookie.indexOf('CM_cookieConsent=1') !== -1 || _isIgnoredCookie(val)) {
80                                    // console.log('Setting cookie: ' + val);
81                                    cookieDesc.set.call(document, val);
82                                } else {
83                                    // console.log('Ignoring cookie: ' + val);
84                                    removedCookies.push(val);
85                                }
86                            }
87                        });
88                    } else {
89                        // for Safari browsers we need to
90                        // check for cookies every second
91                        intervalId = setInterval(function () {
92                            killCookies();
93                        }, 1000);
94                    }
95                }
96            }
97        },
98        isGdprZone: function () {
99            return gdprZone;
100        },
101        consent: function () {
102            // console.log('received consent');
103            if (intervalId !== -1) {
104                clearInterval(intervalId);
105            }
106
107            var cookieDate = new Date;
108            cookieDate.setFullYear(cookieDate.getFullYear() + 2);
109            var cookieExpString = cookieDate.toGMTString();
110            //console.log(cookieExpString);
111
112            document.cookie = 'CM_cookieConsent=1;expires=' + cookieExpString + ';domain=.' + location.host.split(':')[0].split('.').slice(-2).join(".") + ';path=/';
113            var c = '';
114            while (c = removedCookies.pop()) {
115                //console.log(c + ';expires=' + cookieExpString);
116                if (c.indexOf('expires=') !== -1) {
117                    document.cookie = c;
118                } else {
119                    document.cookie = c + ';expires=' + cookieExpString;
120                }
121            }
122            document.dispatchEvent(new Event("CM_consented"));
123        },
124        disConsent: function () {
125            // console.log('received disconsent');
126            if (intervalId !== -1) {
127                clearInterval(intervalId);
128            }
129
130            var cookieDate = new Date;
131            cookieDate.setFullYear(cookieDate.getFullYear() + 2);
132            var cookieExpString = cookieDate.toGMTString();
133
134            document.cookie = 'CM_cookieConsent=0;expires=' + cookieExpString + ';domain=.' + location.host.split(':')[0].split('.').slice(-2).join(".") + ';path=/';
135        },
136        shownBanner: function () {
137          document.dispatchEvent(new Event("CM_shownbanner"));
138        },
139        getRemoved: function () {
140            return removedCookies;
141        },
142        consented: function () {
143          var consented = ! (document.cookie.indexOf('CM_cookieConsent=1') === -1);
144          // console.log("Checking if consent is given:" + consented);
145          return consented;
146        },
147        disconsented: function () {
148          var disconsented = ! (document.cookie.indexOf('CM_cookieConsent=0') === -1);
149          // console.log("Checking if disconsent is given:" + disconsented);
150          return disconsented;
151        }
152    }
153}) ();
154CM_cookieManager.start();

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.