32 lines
944 B
JavaScript
32 lines
944 B
JavaScript
// ================================================================
|
|
// 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';
|
|
|
|
// 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));
|
|
}
|