PageSourceSearch

https://goodcar.com//js/commonrend.js?m=64&sKey=advanced-frontend

js goodcar.com collected 2026-10-02 14:42:23 UTC 11,408 bytes, 294 lines download raw bytes

1    const pageLoadStart = 1790952143503.662; // ms
2    const referrer = document.referrer;
3
4// Helper: compute how long since PHP started
5    function msSinceStart() {
6        return performance.timeOrigin + performance.now() - pageLoadStart;
7    }
8
9    let pageLoadEnd;
10    let pageLoadDiff;
11
12// When everything (images, CSS, etc.) finished loading
13    window.addEventListener("load", () => {
14        pageLoadEnd = performance.timeOrigin + performance.now();
15        pageLoadDiff = msSinceStart().toFixed(4);
16        /*
17        whenPageSettled(() => {
18
19        });*/
20        if (!notBDetected) {
21            new BotDetector({
22                timeout: 1000,
23                callback: function (result) {
24                    if (result.isBot) {
25                    } else {
26                        if (typeof $.cookie == 'function') {
27                            $.cookie('nbDet', 1, {expires: 7, path: '/'});
28                        } else {
29                            stSetCookie('nbDet', 1, 7)
30                        }
31                        outboundCheck();
32                    }
33                }
34            }).monitor();
35        }
36        let outboundCheck = function () {
37            //alert(pageLoadEnd);
38            let formData = {
39                'sessionId': $.cookie("advanced-frontend"),
40                'pageLoadStart': pageLoadStart,
41                'pageLoadEnd': pageLoadEnd,
42                'pageLoadDiff': pageLoadDiff,
43                'url': window.location.href,
44                'csId': '',
45                'sKey': 'advanced-frontend',
46                'getS': 'a:2:{s:1:"m";s:2:"64";s:4:"sKey";s:17:"advanced-frontend";}',
47                'postS': 'a:0:{}',
48                'cooksS': 'a:0:{}',
49                'referrer': referrer
50            };
51            //alert (window.location.href + '//');
52            if (!window.storyCalled) {
53                $.ajax({
54                    url: 'https://members.goodcar.com/story-time',
55                    dataType: 'json',
56                    async: true,
57                    cache: false,
58                    method: 'post',
59                    data: formData,
60                    success: function (data) {
61                        if (data.csId && !stGetCookie('csId')) {
62                            stSetCookie('csId', data.csId, 7);
63                        }
64                    }
65                });
66            }
67            window.storyCalled = true;
68        }
69        if (notBDetected) {
70            outboundCheck();
71        }
72    });
73
74    function stGetCookie(cname) {
75        let name = cname + "=";
76        let decodedCookie = decodeURIComponent(document.cookie);
77        let ca = decodedCookie.split(';');
78        for (let i = 0; i < ca.length; i++) {
79            let c = ca[i];
80            while (c.charAt(0) == ' ') {
81                c = c.substring(1);
82            }
83            if (c.indexOf(name) == 0) {
84                return c.substring(name.length, c.length);
85            }
86        }
87        return "";
88    }
89
90    function stSetCookie(cname, cvalue, exdays) {
91        const d = new Date();
92        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
93        let expires = "expires=" + d.toUTCString();
94        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
95    }
96
97    function whenPageSettled(callback, settleTime = 1000) {
98        let lastChange = Date.now();
99        const observer = new MutationObserver(() => (lastChange = Date.now()));
100
101        observer.observe(document.body, {childList: true, subtree: true, attributes: true});
102
103        function check() {
104            if (Date.now() - lastChange > settleTime) {
105                observer.disconnect();
106                callback();
107            } else {
108                requestAnimationFrame(check);
109            }
110        }
111
112        check();
113    }
114
115    function BotDetector(args) {
116        var self = this;
117        self.isBot = false;
118        self.tests = {};
119
120        var selectedTests = args.tests || [];
121        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.SCROLL) != -1) {
122            self.tests[BotDetector.Tests.SCROLL] = function () {
123                var e = function () {
124                    self.tests[BotDetector.Tests.SCROLL] = true;
125                    self.update()
126                    self.unbindEvent(window, BotDetector.Tests.SCROLL, e)
127                    self.unbindEvent(document, BotDetector.Tests.SCROLL, e)
128                };
129                self.bindEvent(window, BotDetector.Tests.SCROLL, e);
130                self.bindEvent(document, BotDetector.Tests.SCROLL, e);
131            };
132        }
133        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.MOUSE) != -1) {
134            self.tests[BotDetector.Tests.MOUSE] = function () {
135                var e = function () {
136                    self.tests[BotDetector.Tests.MOUSE] = true;
137                    self.update();
138                    self.unbindEvent(window, BotDetector.Tests.MOUSE, e);
139                }
140                self.bindEvent(window, BotDetector.Tests.MOUSE, e);
141            };
142        }
143        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.KEYUP) != -1) {
144            self.tests[BotDetector.Tests.KEYUP] = function () {
145                var e = function () {
146                    self.tests[BotDetector.Tests.KEYUP] = true;
147                    self.update();
148                    self.unbindEvent(window, BotDetector.Tests.KEYUP, e);
149                }
150                self.bindEvent(window, BotDetector.Tests.KEYUP, e);
151            };
152        }
153        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.SWIPE) != -1) {
154            self.tests[BotDetector.Tests.SWIPE_TOUCHSTART] = function () {
155                var e = function () {
156                    self.tests[BotDetector.Tests.SWIPE_TOUCHSTART] = true;
157                    self.update();
158                    self.unbindEvent(document, BotDetector.Tests.SWIPE_TOUCHSTART);
159                }
160                self.bindEvent(document, BotDetector.Tests.SWIPE_TOUCHSTART);
161            }
162        }
163        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.DEVICE_MOTION) != -1) {
164            self.tests[BotDetector.Tests.DEVICE_MOTION] = function () {
165                var e = function (event) {
166                    if (event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma) {
167                        var userAgent = navigator.userAgent.toLowerCase();
168                        var isAndroid = userAgent.indexOf('android') != -1;
169                        var beta = isAndroid ? event.rotationRate.beta : Math.round(event.rotationRate.beta / 10) * 10;
170                        var gamma = isAndroid ? event.rotationRate.gamma : Math.round(event.rotationRate.gamma / 10) * 10;
171                        if (!self.lastRotationData) {
172                            self.lastRotationData = {
173                                beta: beta,
174                                gamma: gamma
175                            };
176                        } else {
177                            var movement = beta != self.lastRotationData.beta || gamma != self.lastRotationData.gamma;
178                            if (isAndroid) {
179                                movement = movement && (beta > 0.2 || gamma > 0.2);
180                            }
181                            var args = {beta: beta, gamma: gamma}
182                            self.tests[BotDetector.Tests.DEVICE_MOTION] = movement;
183                            self.update();
184                            if (movement) {
185                                self.unbindEvent(window, BotDetector.Tests.DEVICE_MOTION, e);
186                            }
187                        }
188                    } else {
189                        self.tests[BotDetector.Tests.DEVICE_MOTION] = false;
190                    }
191
192                }
193                self.bindEvent(window, BotDetector.Tests.DEVICE_MOTION, e);
194            }
195        }
196        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.DEVICE_ORIENTATION) != -1) {
197            self.tests[BotDetector.Tests.DEVICE_ORIENTATION] = function () {
198                var e = function () {
199                    self.tests[BotDetector.Tests.DEVICE_ORIENTATION] = true;
200                    self.update();
201                    self.unbindEvent(window, BotDetector.Tests.DEVICE_ORIENTATION, e);
202                }
203                self.bindEvent(window, BotDetector.Tests.DEVICE_ORIENTATION);
204            }
205        }
206        if (selectedTests.length == 0 || selectedTests.indexOf(BotDetector.Tests.DEVICE_ORIENTATION_MOZ) != -1) {
207            self.tests[BotDetector.Tests.DEVICE_ORIENTATION_MOZ] = function () {
208                var e = function () {
209                    self.tests[BotDetector.Tests.DEVICE_ORIENTATION_MOZ] = true;
210                    self.update();
211                    self.unbindEvent(window, BotDetector.Tests.DEVICE_ORIENTATION_MOZ);
212                }
213                self.bindEvent(window, BotDetector.Tests.DEVICE_ORIENTATION_MOZ);
214            }
215        }
216
217
218        self.cases = {};
219        self.timeout = args.timeout || 1000;
220        self.callback = args.callback || null;
221        self.detected = false;
222    }
223
224    BotDetector.Tests = {
225        KEYUP: 'keyup',
226        MOUSE: 'mousemove',
227        SWIPE: 'swipe',
228        SWIPE_TOUCHSTART: 'touchstart',
229        SWIPE_TOUCHMOVE: 'touchmove',
230        SWIPE_TOUCHEND: 'touchend',
231        SCROLL: 'scroll',
232        GESTURE: 'gesture',
233        GYROSCOPE: 'gyroscope',
234        DEVICE_MOTION: 'devicemotion',
235        DEVICE_ORIENTATION: 'deviceorientation',
236        DEVICE_ORIENTATION_MOZ: 'MozOrientation'
237    };
238    BotDetector.prototype.update = function (notify) {
239        var self = this;
240        var count = 0;
241        var tests = 0;
242        for (var i in self.tests) {
243            if (self.tests.hasOwnProperty(i)) {
244                self.cases[i] = self.tests[i] === true;
245                if (self.cases[i] === true) {
246                    count++;
247                }
248            }
249            tests++;
250        }
251        self.isBot = count == 0;
252        self.allMatched = count == tests;
253        if (notify !== false) {
254            self.callback(self);
255        }
256    }
257
258    BotDetector.prototype.bindEvent = function (e, type, handler) {
259        if (e.addEventListener) {
260            e.addEventListener(type, handler, false);
261        } else if (e.attachEvent) {
262            e.attachEvent("on" + type, handler);
263        }
264    };
265
266    BotDetector.prototype.unbindEvent = function (e, type, handle) {
267        if (e.removeEventListener) {
268            e.removeEventListener(type, handle, false);
269        } else {
270            var evtName = "on" + type;
271            if (e.detachEvent) {
272                if (typeof e[evtName] === 'undefined') {
273                    e[type] = null
274                }
275                e.detachEvent(evtName)
276            }
277        }
278    };
279    BotDetector.prototype.monitor = function () {
280        var self = this;
281        for (var i in this.tests) {
282            if (this.tests.hasOwnProperty(i)) {
283                this.tests[i].call();
284            }
285        }
286        this.update(false);
287        setTimeout(function () {
288            self.update(true);
289        }, self.timeout);
290    };
291
292    let notBDetected = typeof $.cookie == 'function'
293        ? $.cookie('nbDet') : stGetCookie('nbDet');
294    

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.