PageSourceSearch

https://www.motormagasinet.se/js/cookie-consent.js

js motormagasinet.se collected 2026-10-07 21:47:29 UTC 10,703 bytes, 239 lines download raw bytes

1window.thirdPartyConsentAccepted = {
2    StoreAndAccessInformation: false,
3    SelectBasicAds: false,
4    CreateAdsProfile: false,
5    SelectPersonalisedAds: false,
6    CreatePersonalisedProfile: false,
7    SelectPersonalisedContent: false,
8    MeasureAdPerformance: false,
9    MeasureContentPerformance: false,
10    GenerateAudienceInsights: false,
11    DevelopProducts: false,
12    UseGeolocationData: false,
13    ScanDevice: false
14};
15
16window.trackingScriptsEnabled = {
17    Facebook: false,
18    Google: false
19}
20
21/**
22 * This function is called when:
23 *     - the user accepts / rejects / updates the consent terms
24 *     - the user dismisses the consent box by clicking the 'x'
25 *     - the page is loaded (if the consent cookie has already been set)
26 */
27
28function getUserConsentChoices() {
29
30    let thirdPartyPurposeConsentList = undefined;
31    let thirdPartyPurposeConsentListSpecialFeatures = undefined;
32    let indexedPurposesSpecialFeaturesList = {
33        "1": {
34            "id": 1,
35            "name": "Use precise geolocation data"
36        },
37        "2": {
38            "id": 2,
39            "name": "Actively scan device characteristics for identification"
40        }
41    };
42    let indexedPurposesList = {
43        "1": {
44            "id": 1,
45            "name": "Store and/or access information on a device"
46        },
47        "2": {
48            "id": 2,
49            "name": "Select basic ads"
50        },
51        "3": {
52            "id": 3,
53            "name": "Create a personalised ads profile"
54        },
55        "4": {
56            "id": 4,
57            "name": "Select personalised ads"
58        },
59        "5": {
60            "id": 5,
61            "name": "Create a personalised content profile"
62        },
63        "6": {
64            "id": 6,
65            "name": "Select personalised content"
66        },
67        "7": {
68            "id": 7,
69            "name": "Measure ad performance"
70        },
71        "8": {
72            "id": 8,
73            "name": "Measure content performance"
74        },
75        "9": {
76            "id": 9,
77            "name": "Apply market research to generate audience insights"
78        },
79        "10": {
80            "id": 10,
81            "name": "Develop and improve products"
82        }
83    };
84
85    // get transparency and consent data - check 3rd party cookie consent
86    __tcfapi('getTCData', 2, function(tcData, success) {
87        if (success) {
88            //console.log('getTCDate result: ', tcData);
89            thirdPartyPurposeConsentList = tcData.purpose.consents;
90            thirdPartyPurposeConsentListSpecialFeatures = tcData.specialFeatureOptins;
91            enforceConsent(indexedPurposesList, indexedPurposesSpecialFeaturesList, thirdPartyPurposeConsentList, thirdPartyPurposeConsentListSpecialFeatures, tcData.gdprApplies, tcData.tcString);
92        }
93    });
94
95}
96
97/**
98 * filters object based on name and returns the id
99 * @param object
100 * @param value
101 */
102function filterObject(object, value) {
103    let keys = Object.keys(object);
104    for (var i = 0; i < keys.length; i++) {
105        if (object[keys[i]].name === value) {
106            return object[keys[i]].id;
107        }
108    }
109    return undefined;
110}
111
112/**
113 * check if function exists before calling it
114 * @param fn
115 */
116function callFunction(fn) {
117    if ($.isFunction(fn)) {
118        fn();
119    }
120}
121
122/**
123 * Enforce consent.
124 * @param indexedPurposesList
125 * @param indexedPurposesSpecialFeaturesList
126 * @param thirdPartyPurposeConsentList
127 * @param thirdPartyPurposeConsentListSpecialFeatures
128 */
129function enforceConsent(indexedPurposesList, indexedPurposesSpecialFeaturesList, thirdPartyPurposeConsentList, thirdPartyPurposeConsentListSpecialFeatures, gdprApplies, tcString) {
130    /* **********************************************
131         * Extract user consent settings from QuantCast *
132         * **********************************************/
133
134    // set consent choices
135    let thirdPartyConsentChoices = {
136        StoreAndAccessInformation: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Store and/or access information on a device")],
137        SelectBasicAds: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Select basic ads")],
138        CreateAdsProfile: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Create a personalised ads profile")],
139        SelectPersonalisedAds: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Select personalised ads")],
140        CreatePersonalisedProfile: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Create a personalised content profile")],
141        SelectPersonalisedContent: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Select personalised content")],
142        MeasureAdPerformance: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Measure ad performance")],
143        MeasureContentPerformance: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Measure content performance")],
144        GenerateAudienceInsights: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Apply market research to generate audience insights")],
145        DevelopProducts: thirdPartyPurposeConsentList[filterObject(indexedPurposesList, "Develop and improve products")],
146        UseGeolocationData: thirdPartyPurposeConsentListSpecialFeatures[filterObject(indexedPurposesSpecialFeaturesList, "Use precise geolocation data")],
147        ScanDevice: thirdPartyPurposeConsentListSpecialFeatures[filterObject(indexedPurposesSpecialFeaturesList, "Actively scan device characteristics for identification")]
148    };
149
150    window.thirdPartyConsentAccepted.StoreAndAccessInformation = thirdPartyConsentChoices.StoreAndAccessInformation !== undefined ? thirdPartyConsentChoices.StoreAndAccessInformation : false;
151    window.thirdPartyConsentAccepted.SelectBasicAds = thirdPartyConsentChoices.SelectBasicAds !== undefined ? thirdPartyConsentChoices.SelectBasicAds : false;
152    window.thirdPartyConsentAccepted.CreateAdsProfile = thirdPartyConsentChoices.CreateAdsProfile !== undefined ? thirdPartyConsentChoices.CreateAdsProfile : false;
153    window.thirdPartyConsentAccepted.SelectPersonalisedAds = thirdPartyConsentChoices.SelectPersonalisedAds !== undefined ? thirdPartyConsentChoices.SelectPersonalisedAds : false;
154    window.thirdPartyConsentAccepted.CreatePersonalisedProfile = thirdPartyConsentChoices.CreatePersonalisedProfile !== undefined ? thirdPartyConsentChoices.CreatePersonalisedProfile : false;
155    window.thirdPartyConsentAccepted.SelectPersonalisedContent = thirdPartyConsentChoices.SelectPersonalisedContent !== undefined ? thirdPartyConsentChoices.SelectPersonalisedContent : false;
156    window.thirdPartyConsentAccepted.MeasureAdPerformance = thirdPartyConsentChoices.MeasureAdPerformance !== undefined ? thirdPartyConsentChoices.MeasureAdPerformance : false;
157    window.thirdPartyConsentAccepted.MeasureContentPerformance = thirdPartyConsentChoices.MeasureContentPerformance !== undefined ? thirdPartyConsentChoices.MeasureContentPerformance : false;
158    window.thirdPartyConsentAccepted.GenerateAudienceInsights = thirdPartyConsentChoices.GenerateAudienceInsights !== undefined ? thirdPartyConsentChoices.GenerateAudienceInsights : false;
159    window.thirdPartyConsentAccepted.DevelopProducts = thirdPartyConsentChoices.DevelopProducts !== undefined ? thirdPartyConsentChoices.DevelopProducts : false;
160    window.thirdPartyConsentAccepted.UseGeolocationData = thirdPartyConsentChoices.UseGeolocationData !== undefined ? thirdPartyConsentChoices.UseGeolocationData : false;
161    window.thirdPartyConsentAccepted.ScanDevice = thirdPartyConsentChoices.ScanDevice !== undefined ? thirdPartyConsentChoices.ScanDevice : false;
162
163
164    // enable Facebook and Google tracking
165    window.trackingScriptsEnabled.Facebook = window.trackingScriptsEnabled.Google =
166        window.thirdPartyConsentAccepted.CreateAdsProfile &&
167        window.thirdPartyConsentAccepted.SelectPersonalisedAds &&
168        window.thirdPartyConsentAccepted.MeasureAdPerformance;
169
170    /* ***************************************************************
171     * Determine which scripts and partials should be enabled/loaded *
172     * ***************************************************************/
173
174    // Google Tag Manager
175    callFunction(window.enableGTM); // google-tag-manager.xhtml
176
177    // google analytics
178    if (window.trackingScriptsEnabled.Google) {
179        callFunction(window.enableGoogleAnalytics); // google-analytics-consent.xhtml
180    } else {
181        callFunction(window.disableGoogleAnalytics); // google-analytics-consent.xhtml
182    }
183
184    // facebook script
185    if (window.trackingScriptsEnabled.Facebook) {
186        callFunction(window.enableFacebookPixel); // facebook-consent.xhtml
187    }
188    else {
189        callFunction(window.disableFacebookPixel); // facebook-consent.xhtml
190    }
191
192    // Banners
193    window["banner-consent-data"] = {
194        gdprApplies: gdprApplies,
195        tcString: tcString
196    }
197    callFunction(window.enableBanners); // banner-consent.xhtml
198
199    // Hotjar
200    callFunction(window.enableHotjar); // hotjar-consent.xhtml
201
202    // LinkedIn Insights
203    callFunction(window.enableLinkedinInsights); // linkedin-insights-consent.xhtml
204
205    /* ************************************************************************
206            * process queued up script executions such as widgets and other tracking *
207            * ************************************************************************/
208    // first capture push function, so new calls are executed immediately
209    window.pendingScriptExecutions.push = function (callbackObj) {
210        if (callbackObj.callback instanceof Function) {
211            callbackObj.callback.call(callbackObj.context);
212        }
213        return 0;
214    };
215
216    // then empty the existing queue of callbacks already added
217    window.pendingScriptExecutions.forEach(function (v, i, a) {
218        window.pendingScriptExecutions.push(v);
219    });
220}
221
222(function () {
223    __tcfapi('addEventListener', 2, function (tcData, success) {
224        if (success) {
225            if (tcData.eventStatus === 'tcloaded') {
226                // this function is called when the page is loaded
227                if (tcData.tcString !== null && tcData.tcString.length > 0) {
228                    // Only proceed if we already have consent string
229                    getUserConsentChoices();
230                }
231            } else if (tcData.eventStatus === 'useractioncomplete') {
232                // this function is called when:
233                // - the user accepts / rejects / updates the consent terms
234                // - the user dismisses the consent box by clicking the 'x'
235                getUserConsentChoices();
236            }
237        }
238    });
239})();

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.