PageSourceSearch

https://www.also.pt/ec/cms5/media/js/moduls/script_usercentrics.js

js also.pt collected 2026-10-09 22:41:52 UTC 11,967 bytes, 292 lines download raw bytes

1
2/*;(function ($, window, document, undefined) {
3
4    "use strict";
5
6    // Create the defaults once
7    var pluginName = "cmp_enhancer",
8        defaults = {
9            dppIdentifierContainer: "footer",
10            dppIdentifierString: "DPP",
11            dppIdentifierDataAttribute: "legaltype",
12            dppIdentifierLink: "",
13            cmpObject: "usercentrics",
14            cmpIdentifier: ".usercentrics-button",
15            cmpDPPlink: "a[href*='legal\/data-privacy-statement']",
16            observer: "",
17            observerConfig: {"attributes": true, "childList": true, "subtree": true},
18            observerTargetNode: "",
19            observerCallback: "",
20            openUCdpp: "[data-event=open-consent-info-modal]",
21            openALSOdpp: "open-ALSO-dpp"
22        };
23
24    // The actual plugin constructor
25    function Plugin(element, options) {
26        this.element = element;
27
28        this.settings = $.extend({}, defaults, options);
29        this._defaults = defaults;
30        this._name = pluginName;
31        this.init();
32    }
33
34    // Avoid Plugin.prototype conflicts
35    $.extend(Plugin.prototype, {
36        init: function () {
37			if (window.document.documentMode) $("body").addClass("uc-fix-IE");
38			if($("body[class*=shop]").length) this.settings.dppIdentifierContainer = "#footermenu";
39            this.checkForDPPLink();
40        },
41        checkForDPPLink: function () {
42            //console.log("call checkForDPPLink");
43
44            var $dppLinkElement = $(this.settings.dppIdentifierContainer).find("a[data-" + this.settings.dppIdentifierDataAttribute + "=" + this.settings.dppIdentifierString + "]").eq(0);
45            if ($dppLinkElement.length !== 0) {
46                this.settings.dppIdentifierLink = $dppLinkElement[0].href;
47                this.checkIfCMPisActive();
48            } else {
49                console.log("No DPP link found!");
50            }
51        },
52        checkIfCMPisActive: function () {
53            //console.log("call checkIfCMPisActive");
54
55            var that = this;
56            if (window[that.settings.cmpObject] !== undefined) {
57                if (window[that.settings.cmpObject].isInitialized) {
58                    that.initHandlers(that.settings.cmpIdentifier);
59                    return;
60                }
61            }
62            that.initObserver("body");
63
64        },
65        updateCMPlinksDPP: function () {
66            //console.log("call updateCMPlinksDPP");
67
68            var that = this,
69                linkCount = 0,
70                ucBannerPrivacyUrl = $(".uc-banner-privacyurl")[0];
71
72            if (ucBannerPrivacyUrl !== undefined) {
73                ucBannerPrivacyUrl.href = that.settings.dppIdentifierLink;
74            }
75
76            $(this.settings.cmpIdentifier)
77                .find(that.settings.cmpDPPlink)
78                .each(function () {
79                    //console.log("found legal link: "+this);
80                    this.href = that.settings.dppIdentifierLink;
81                    linkCount++;
82                    //console.log(this.href);
83                })
84            ;
85
86            if (!linkCount) {
87                console.log("no legal links found");
88            }
89        },
90        initHandlers: function (target) {
91            //console.log("call initHandlers");
92
93            this.updateCMPlinksDPP();
94            this.initObserver(target);
95            this.initEventListeners();
96        },
97        initObserver: function (obsTarget) {
98            //console.log("call initObserver");
99
100            var that = this;
101
102            this.settings.observerCallback = this.initObserverCallback();
103            this.settings.observerTargetNode = $(obsTarget);
104            this.settings.observer = new MutationObserver(this.settings.observerCallback);
105
106            //for (let targetNode of this.settings.observerTargetNode.get()) {
107            this.settings.observerTargetNode.get().forEach(function(targetNode) {
108                that.settings.observer.observe(targetNode, that.settings.observerConfig);
109                //console.log(targetNode);
110            });
111
112
113
114        },
115        initObserverCallback: function () {
116            //console.log("call initObserverCallback");
117
118            var that = this;
119            return function (mutationsList, observer) {
120
121                //for (let mutation of mutationsList) {
122                mutationsList.forEach(function(mutation) {
123                    if (mutation.type === 'childList') {
124                        //console.log('A child node has been added or removed.');
125                        //console.log(mutation);
126                        if (mutation.addedNodes.length > 0) {
127                            if (mutation.addedNodes[0].id === "usercentrics-button") {
128                                //console.log("#usercentrics-button was added!");
129                                that.killObserver();
130                                that.initHandlers(that.settings.cmpIdentifier);
131                            }
132                        }
133                        if (mutation.target.className !== "uc-container") {
134                            that.updateCMPlinksDPP();
135                        }
136                    }
137                });
138            };
139        },
140        killObserver: function () {
141            //console.log("call killObserver");
142
143            this.settings.observer.disconnect();
144        },
145        initEventListeners: function () {
146            //console.log("call initEventListeners");
147
148            var that = this;
149            $(that.settings.cmpIdentifier)
150                .off("click", "[data-event=open-consent-info-modal]")
151                .on("click", "[data-event=open-consent-info-modal]", function (e) {
152                    e.preventDefault();
153                    var adjustedLink = that.settings.dppIdentifierLink + "#" + $(this).data("id");
154                    window.location.href = adjustedLink;
155                    //console.log("changed click target to " + adjustedLink);
156                })
157            ;
158        }
159    });
160
161    $.fn[pluginName] = function (options) {
162        return this.each(function () {
163            if (!$.data(this, "plugin_" + pluginName)) {
164                $.data(this, "plugin_" +
165                    pluginName, new Plugin(this, options));
166            }
167        });
168    };
169
170})(jQuery, window, document);
171
172
173$(window).on('load', function () {
174    $("body").cmp_enhancer();
175});
176*/
177const legal_urls = [
178	"/ec/cms5/de_1010/1010/legal/datenschutzerklaerung/index.jsp",
179	"/ec/cms5/en_1010/1010/legal/datenschutzerklaerung/index.jsp",
180	"/ec/cms5/fr_2000/2000/mentions-legales/cnil/index.jsp",
181	"/ec/cms5/de_2200/2200/rechtliches/datenschutzerklaerung/index.jsp",
182	"/ec/cms5/nl_2320/2320/legal/gegevensbescherming/index.jsp",
183	"/ec/cms5/fr_2320/2320/legal/cnil/index.jsp",
184	"/ec/cms5/nl_2420/2420/legal/gegevensbescherming/index.jsp",
185	"/ec/cms5/de_2420/2420/legal/data-privacy-statement/index.jsp",
186	"/ec/cms5/en_2420/2420/legal/data-privacy-statement/index.jsp",
187	"/ec/cms5/fr_2420/2420/legal/data-privacy-statement/index.jsp",
188	"/ec/cms5/es_2420/2420/legal/data-privacy-statement/index.jsp",
189	"/ec/cms5/pt_2420/2420/legal/data-privacy-statement/index.jsp",
190    "/ec/cms5/en_2421/2421/legal/general-terms-and-conditions/index.jsp",
191	"https://www.westcoastcloud.co.uk/privacy/",
192	"/ec/cms5/es_2610/2610/legal/data-privacy-statement/index.jsp",
193    "/ec/cms5/pt_2640/2640/legal/termos-de-uso/index.jsp",
194	"/ec/cms5/it_2710/2710/legal/data-privacy-statement/index.jsp",
195	"/ec/cms5/it_2710/2710/legal/data-privacy-statement/index.jsp",
196	"/ec/cms5/da_2800/2800/juridisk/data-fortrolighed/index.jsp",
197	"/ec/cms5/no_2900/2900/legal/personvernerklaering/index.jsp",
198	"/ec/cms5/sv_3100/3100/juridiskt/data-sekretesspolicy/data_privacy_statement_v3_2.jsp",
199	"/ec/cms5/de_3310/3310/legal/data-privacy-statement/index.jsp",
200	"/ec/cms5/nl_3310/3310/legal/data-privacy-statement/index.jsp",
201	"/ec/cms5/en_3310/3310/legal/data-privacy-statement/index.jsp",
202	"/ec/cms5/de_3340/3340/legal/datenschutzerklaerung/index.jsp",
203	"/ec/cms5/de_4111/4111/legal/datenschutzerklaerung/index.jsp",
204	"/ec/cms5/de_4112/4112/legal/datenschutzerklaerung/index.jsp",
205	"/ec/cms5/en_4112/4112/legal/data-privacy-statement/index.jsp",
206	"/ec/cms5/et_5110/5110/juriidika/teade-isikuandmete-kaitse-kohta/index.jsp",
207	"/ec/cms5/en_5110/5110/legal/data-privacy-statement/index.jsp",
208	"/ec/cms5/lv_5210/5210/legal/datu-privatuma-zinojums/data_privacy_statement_211.jsp",
209	"/ec/cms5/en_5210/5210/legal/data-privacy-statement/data_privacy_statement_211.jsp",
210	"/ec/cms5/lt_5310/5310/privatumo-politika/privatumo-politika/index.jsp",
211	"/ec/cms5/en_5310/5310/legal/data-privacy-statement/index.jsp",
212	"/ec/cms5/pl_5410/5410/legal/polityka-prywatnosci/index.jsp",
213	"/ec/cms5/fi_5710/5710/ehdot/tietosuoja/index.jsp",
214	"/ec/cms5/en_5710/5710/legal/data-privacy-statement/index.jsp",
215	"/ec/cms5/sl_5820/5820/pravo/pravilnik-o-zasebnosti/index.jsp",
216	"/ec/cms5/hr_5830/5830/legal/data-privacy-statement/index.jsp",
217	"/ec/cms5/sk_5840/5840/pravne-informacie/prehlasenie-o-ochrane-osobnych-udajov/index.jsp",
218	"/ec/cms5/cs_5845/5845/pravni-informace/prohlaseni-o-ochrane-osobnich-udaju/index.jsp",
219	"/ec/cms5/hu_5850/5850/jogi-nyilatkozat/adatvedelmi-nyilatkozat/index.jsp",
220	"/ec/cms5/ro_5860/5860/legal/declaratia-de-confidentialitate-a-datelor/index.jsp",
221	"/ec/cms5/bg_5870/5870/legal/data-privacy-statement/index.jsp",
222	"/ec/cms5/en_6000/6000/legal/data-privacy-statement/index.jsp",
223	"/ec/cms5/de_6000/6000/legal/datenschutzerklaerung/index.jsp",
224	"/ec/cms5/de_6110/6110/legal/datenschutzerklaerung/index.jsp",
225	"/ec/cms5/fr_6110/6110/legal/declaration-de-confidentialite/index.jsp",
226	"/ec/cms5/it_6110/6110/legal/datenschutzerklaerung/index.jsp"
227  ];
228  
229  /*window.addEventListener('load', function() {
230  const ucRoot = document.querySelector("#usercentrics-root");
231  //console.log("Root", ucRoot);
232  
233  if (ucRoot) {
234    const ucShadow = ucRoot.shadowRoot;
235  
236    if (ucShadow) {
237      const observer = new MutationObserver((mutationsList, observer) => {
238        for (let mutation of mutationsList) {
239          if (mutation.type === "childList") {
240            const ucLink = ucShadow.querySelector("#uc-show-more > div > a");
241            
242            if (ucLink) {
243              //console.log("Link found:", ucLink);
244              const myStr = window.pegasos.language + "_" + window.pegasos.salesorgNo;
245              const myHref = legal_urls.find((url) => url.includes(myStr));
246  
247              ucLink.href = myHref;
248              observer.disconnect();
249            }
250          }
251        }
252      });
253  
254      const config = { attributes: true, childList: true, subtree: true };
255      observer.observe(ucShadow, config);
256    }
257  }
258  });*/
259
260  //works for usercentrics v2 & v3
261(function () {
262    function patch(shadow) {
263        const ucLink = shadow.querySelector(".privacy-text-detailed a") || shadow.querySelector("#uc-show-more > div > a");
264        if (!ucLink) return;
265        const myStr  = window.pegasos.language + "_" + window.pegasos.salesorgNo;
266        const myHref = legal_urls.find((url) => url.includes(myStr));
267        if (myHref && !ucLink.href.includes(myStr)) ucLink.href = myHref;
268    }
269
270    function attachObserver() {
271        const ucRoot = document.querySelector("#usercentrics-cmp-ui") || document.querySelector("#usercentrics-root");
272        if (!ucRoot || !ucRoot.shadowRoot) return false;
273        const shadow = ucRoot.shadowRoot;
274        patch(shadow);
275        new MutationObserver(() => patch(shadow)).observe(shadow, { childList: true, subtree: true });
276        return true;
277    }
278
279    function start() {
280        if (!attachObserver()) {
281            new MutationObserver(function (_, bodyObserver) {
282                if (attachObserver()) bodyObserver.disconnect();
283            }).observe(document.body, { childList: true, subtree: true });
284        }
285    }
286
287    if (document.body) {
288        start();
289    } else {
290        document.addEventListener('DOMContentLoaded', start);
291    }
292})();

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.