PageSourceSearch

https://sql-test.online/js/analytics.js?20261009

js sql-test.online collected 2026-10-09 23:10:10 UTC 3,473 bytes, 107 lines download raw bytes

1(function () {
2    if (window.__sqltestAnalyticsLoaderInitialized) {
3        return;
4    }
5    window.__sqltestAnalyticsLoaderInitialized = true;
6
7    const scriptPromises = {};
8
9    function loadExternalScriptOnce(src) {
10        if (scriptPromises[src]) {
11            return scriptPromises[src];
12        }
13
14        scriptPromises[src] = new Promise((resolve, reject) => {
15            const existingScript = document.querySelector(`script[src="${src}"]`);
16            if (existingScript) {
17                if (existingScript.dataset.loaded === 'true') {
18                    resolve();
19                    return;
20                }
21
22                existingScript.addEventListener('load', () => resolve(), { once: true });
23                existingScript.addEventListener('error', () => reject(new Error(`Failed to load script: ${src}`)), { once: true });
24                return;
25            }
26
27            const script = document.createElement('script');
28            script.src = src;
29            script.async = true;
30            script.onload = () => {
31                script.dataset.loaded = 'true';
32                resolve();
33            };
34            script.onerror = () => reject(new Error(`Failed to load script: ${src}`));
35            document.head.appendChild(script);
36        });
37
38        return scriptPromises[src];
39    }
40
41    function runWhenBrowserIdle(callback, timeout) {
42        if ('requestIdleCallback' in window) {
43            window.requestIdleCallback(callback, { timeout });
44            return;
45        }
46
47        window.setTimeout(callback, 1500);
48    }
49
50    function initGoogleTagManager(googleTagManagerId) {
51        if (!googleTagManagerId || window.__sqltestGtmInitialized) {
52            return;
53        }
54
55        window.__sqltestGtmInitialized = true;
56        window.dataLayer = window.dataLayer || [];
57        window.gtag = window.gtag || function () {
58            window.dataLayer.push(arguments);
59        };
60        window.gtag('js', new Date());
61        window.gtag('config', googleTagManagerId);
62
63        loadExternalScriptOnce(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(googleTagManagerId)}`)
64            .catch((error) => console.error(error));
65    }
66
67    function initYandexMetrika(yandexMetrikaId) {
68        if (!yandexMetrikaId || window.__sqltestMetrikaInitialized) {
69            return;
70        }
71
72        window.__sqltestMetrikaInitialized = true;
73        window.ym = window.ym || function () {
74            (window.ym.a = window.ym.a || []).push(arguments);
75        };
76        window.ym.l = Date.now();
77        window.ym(yandexMetrikaId, 'init', {
78            clickmap: true,
79            trackLinks: true,
80            accurateTrackBounce: true,
81            webvisor: false,
82            trackHash: false
83        });
84
85        loadExternalScriptOnce('https://mc.yandex.ru/metrika/tag.js')
86            .catch((error) => console.error(error));
87    }
88
89    function initAnalytics() {
90        const googleTagManagerId = window.AppConfig?.googleTagManagerId || '';
91        const yandexMetrikaId = window.AppConfig?.yandexMetrikaId || '';
92
93        initGoogleTagManager(googleTagManagerId);
94        initYandexMetrika(yandexMetrikaId);
95    }
96
97    function scheduleAnalyticsInit() {
98        runWhenBrowserIdle(initAnalytics, 2500);
99    }
100
101    if (document.readyState === 'complete') {
102        scheduleAnalyticsInit();
103        return;
104    }
105
106    window.addEventListener('load', scheduleAnalyticsInit, { once: true });
107})();

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.