PageSourceSearch

https://insight.hidrabene.com.br/events.js

js hidrabene.com.br collected 2026-09-29 00:10:09 UTC 5,269 bytes, 154 lines download raw bytes

1function getCookie(name) {
2    var value = "; " + document.cookie;
3    var parts = value.split("; " + name + "=");
4    if (parts.length >= 2) return parts.pop().split(";").shift();
5}
6
7function submitEvent(hostname, type) {
8    var clickId = getCookie('rtkclickid-store');
9    if (!clickId || clickId === 'undefined') {
10        clickId = sessionStorage.getItem("rtkclickid");
11    }
12    if (!clickId || clickId === 'undefined') {
13        setTimeout(function () {
14            submitEvent(hostname, type);
15        }, 1000);
16        return;
17    }
18    console.log(type);
19    var xhr = new XMLHttpRequest;
20    xhr.open("GET", `${hostname}/postback?clickid=${clickId}&type=${type}&eventid=${clickId}`);
21    xhr.send();
22    if (type === 'viewcontent' || type === 'addtocart') {
23        var xhr2 = new XMLHttpRequest;
24        xhr2.open("POST", '/cart/update.js');
25        xhr2.setRequestHeader("Content-Type", "application/json");
26        xhr2.send(
27            JSON.stringify({
28                attributes: {
29                    '__clickid': clickId,
30                }
31            })
32        );
33    }
34}
35
36function detectProductByMeta() {
37    try {
38        return meta && meta.product;
39    } catch (e) {
40        return false;
41    }
42}
43
44function detectProductByCartForm() {
45    return document.querySelector("form[action='/cart/add']");
46}
47
48var pathArray = document.currentScript.src.split('/');
49var protocol = pathArray[0];
50var host = pathArray[2];
51var hostname = protocol + '//' + host;
52var cartFormDetected = false;
53var isProduct = false;
54document.addEventListener("DOMContentLoaded", function () {
55    if (detectProductByMeta() || detectProductByCartForm()) {
56        isProduct = true;
57    } else {
58        var path = window.location.pathname;
59        var potentialHandle = path.substring(path.lastIndexOf("/") + 1);
60        var xhr = new XMLHttpRequest;
61        xhr.onreadystatechange = function () {
62            if (xhr.status == 200) {
63                submitEvent(hostname, 'viewcontent');
64            }
65        };
66        xhr.open("GET", `/products/${potentialHandle}.json`);
67        xhr.send();
68    }
69    if (isProduct) {
70        submitEvent(hostname, 'viewcontent');
71
72        document.body.addEventListener('click', function (event) {
73            if (event.target.className && event.target.className.toString().indexOf('shopify-payment-button__button') !== -1) {
74                submitEvent(hostname, 'buynow');
75            }
76            ;
77        });
78    }
79
80    var cartForms = document.querySelectorAll("form[action='/cart/add']");
81    if (cartForms) {
82        cartForms.forEach(function (cartForm) {
83            cartForm.addEventListener("submit", function (e) {
84                submitEvent(hostname, 'addtocart');
85                cartFormDetected = true;
86            });
87        });
88    }
89});
90
91(function () {
92    var open = window.XMLHttpRequest.prototype.open;
93
94    function openReplacement() {
95        this.addEventListener("load", function () {
96            if (this._url && this._url.indexOf('/products/') !== -1 && this._url.indexOf('view=ajax') !== -1) {
97                submitEvent(hostname, 'viewcontent');
98
99                setTimeout(function () {
100                    var cartForms = document.querySelectorAll("form[action='/cart/add']");
101                    if (cartForms) {
102                        cartForms.forEach(function (cartForm) {
103                            cartForm.addEventListener("submit", function (e) {
104                                submitEvent(hostname, 'addtocart');
105                                cartFormDetected = true;
106                            });
107                        });
108                    }
109                }, 2000);
110            }
111            if (
112                [
113                    `${window.location.origin}/cart/add.js`,
114                    //`${window.location.origin}/cart/update.js`,
115                    //`${window.location.origin}/cart/change.js`,
116                    //`${window.location.origin}/cart/clear.js`,
117                ].includes((this._url ? this._url.split('?')[0] : this._url))
118            ) {
119                if (!cartFormDetected) {
120                    submitEvent(hostname, 'addtocart');
121                }
122            }
123        });
124        return open.apply(this, arguments);
125    }
126
127    window.XMLHttpRequest.prototype.open = openReplacement;
128})();
129
130(function (ns, fetch) {
131    if (typeof fetch !== 'function') return;
132
133    ns.fetch = function () {
134        var response = fetch.apply(this, arguments);
135
136        response.then(res => {
137            if ([
138                `${window.location.origin}/cart/add.js`,
139                //`${window.location.origin}/cart/update.js`,
140                //`${window.location.origin}/cart/change.js`,
141                //`${window.location.origin}/cart/clear.js`,
142            ].includes((res.url ? res.url.split('?')[0] : res.url))) {
143                res.clone().json().then(data => {
144                    if (!cartFormDetected) {
145                        submitEvent(hostname, 'addtocart');
146                    }
147                });
148            }
149        });
150
151        return response;
152    }
153
154}(window, window.fetch))

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.