HackTimer V1

Uses a Web Worker to ensure high-precision timing for setInterval and setTimeout.

2025-10-18 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/552983/1679792/HackTimer%20V1.js

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @license      MIT
// @name         HackTimer V1
// @namespace    HackTimer
// @version      1.0.7.2
// @description  Uses a Web Worker to ensure high-precision timing for setInterval and setTimeout.
// @grant        none
// ==/UserScript==

(function (workerScript) {
    if (!/MSIE 10/i.test(navigator.userAgent)) {
        try {
            var blob = new Blob([`
var fakeIdToId = {};
onmessage = function (event) {
    var data = event.data,
        name = data.name,
        fakeId = data.fakeId,
        time;
    if (data.hasOwnProperty('time')) {
        time = data.time;
    }
    switch (name) {
        case 'setInterval':
            fakeIdToId[fakeId] = setInterval(function () {
                postMessage({fakeId: fakeId});
            }, time);
            break;
        case 'clearInterval':
            if (fakeIdToId.hasOwnProperty(fakeId)) {
                clearInterval(fakeIdToId[fakeId]);
                delete fakeIdToId[fakeId];
            }
            break;
        case 'setTimeout':
            fakeIdToId[fakeId] = setTimeout(function () {
                postMessage({fakeId: fakeId});
                if (fakeIdToId.hasOwnProperty(fakeId)) {
                    delete fakeIdToId[fakeId];
                }
            }, time);
            break;
        case 'clearTimeout':
            if (fakeIdToId.hasOwnProperty(fakeId)) {
                clearTimeout(fakeIdToId[fakeId]);
                delete fakeIdToId[fakeId];
            }
            break;
    }
}
`], { type: 'application/javascript' });
            workerScript = window.URL.createObjectURL(blob);
        } catch (error) {
            console.warn('HackTimer: Blob not supported, using external script');
        }
    }

    var worker,
        fakeIdToCallback = new Map(),
        lastFakeId = 0,
        maxFakeId = 0x9FFFFFFF,
        logPrefix = 'HackTimer: ';

    if (typeof Worker !== 'undefined') {
        function getFakeId() {
            do {
                lastFakeId = (lastFakeId === maxFakeId) ? 0 : lastFakeId + 0.37;
            } while (fakeIdToCallback.has(lastFakeId));
            return lastFakeId;
        }

        function executeCallback(fakeId) {
            const request = fakeIdToCallback.get(fakeId);
            if (!request) return;

            const { callback, parameters, isTimeout } = request;
            
            if (isTimeout) {
                fakeIdToCallback.delete(fakeId);
            }

            let callbackFunc = callback;
            if (typeof callback === 'string') {
                try {
                    callbackFunc = new Function(callback);
                } catch (error) {
                    console.error(logPrefix + 'Error parsing callback:', error);
                    return;
                }
            }

            if (typeof callbackFunc === 'function') {
                try {
                    callbackFunc.apply(window, parameters);
                } catch (error) {
                    console.error(logPrefix + 'Error executing callback:', error);
                }
            }
        }

        try {
            worker = new Worker(workerScript);
            
            const originalSetInterval = window.setInterval;
            const originalClearInterval = window.clearInterval;
            const originalSetTimeout = window.setTimeout;
            const originalClearTimeout = window.clearTimeout;

            window.setInterval = function (callback, time, ...parameters) {
                const fakeId = getFakeId();
                fakeIdToCallback.set(fakeId, {
                    callback: callback,
                    parameters: parameters,
                    isTimeout: false
                });
                worker.postMessage({
                    name: 'setInterval',
                    fakeId: fakeId,
                    time: Math.max(0, time || 0)
                });
                return fakeId;
            };

            window.clearInterval = function (fakeId) {
                if (fakeIdToCallback.has(fakeId)) {
                    fakeIdToCallback.delete(fakeId);
                    worker.postMessage({
                        name: 'clearInterval',
                        fakeId: fakeId
                    });
                }
            };

            window.setTimeout = function (callback, time, ...parameters) {
                const fakeId = getFakeId();
                fakeIdToCallback.set(fakeId, {
                    callback: callback,
                    parameters: parameters,
                    isTimeout: true
                });
                worker.postMessage({
                    name: 'setTimeout',
                    fakeId: fakeId,
                    time: Math.max(0, time || 0)
                });
                return fakeId;
            };

            window.clearTimeout = function (fakeId) {
                if (fakeIdToCallback.has(fakeId)) {
                    fakeIdToCallback.delete(fakeId);
                    worker.postMessage({
                        name: 'clearTimeout',
                        fakeId: fakeId
                    });
                }
            };

            worker.onmessage = function (event) {
                const { fakeId } = event.data;
                executeCallback(fakeId);
            };

            worker.onerror = function (event) {
                console.error(logPrefix + 'Worker error:', event);
            };

        } catch (error) {
            console.error(logPrefix + 'Initialisation failed:', error);
        }
    } else {
        console.warn(logPrefix + 'Web Workers not supported');
    }
})('HackTimerWorker.js');