MJ: claude fix
This commit is contained in:
@@ -1,21 +1,31 @@
|
||||
// ================================================================
|
||||
// 00_config.js — Shared constants and utility helpers
|
||||
// Runs first; everything here is available to all other modules.
|
||||
// ================================================================
|
||||
|
||||
const uw = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
|
||||
const BASE_URL = 'https://grepo.haunter-pets.top';
|
||||
const uw = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;
|
||||
const BASE_URL = 'https://grepo.haunter-pets.top';
|
||||
|
||||
// ---- Jitter helpers -----------------------------------------------
|
||||
// Returns a random integer between min and max (inclusive)
|
||||
function randInt(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
// Schedules fn to run after a random ms delay, then reschedules itself
|
||||
function jitterLoop(fn, minMs, maxMs) {
|
||||
function schedule() {
|
||||
setTimeout(async () => {
|
||||
await fn();
|
||||
schedule(); // reschedule with a NEW random delay every time
|
||||
}, randInt(minMs, maxMs));
|
||||
}
|
||||
schedule();
|
||||
// Returns a random integer between min and max (inclusive)
|
||||
function randInt(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
// Schedules fn to run after a random ms delay, then reschedules itself
|
||||
function jitterLoop(fn, minMs, maxMs) {
|
||||
function schedule() {
|
||||
setTimeout(async () => {
|
||||
await fn();
|
||||
schedule();
|
||||
}, randInt(minMs, maxMs));
|
||||
}
|
||||
schedule();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
function log(msg) {
|
||||
console.log(`[GRC] ${msg}`);
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(r => setTimeout(r, ms));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user