Update bootstrap.js
This commit is contained in:
1 parent
e78b5e6026
commit
3d39e59c14
1 file changed
+17
-4
Vendored
+17
-4
@@ -406,12 +406,24 @@ const _scheduleAfter = (delay, fn) => {
|
|||||||
else Deno.core.ops.op_sleep(d).then(fn);
|
else Deno.core.ops.op_sleep(d).then(fn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Timers accept a string first arg per the HTML spec (e.g. the Aliyun WAF
|
||||||
|
// `acw_sc__v2` challenge drives `setTimeout('reload(arg2)', 2)`). A string is
|
||||||
|
// compiled and run in global scope, identical to a real browser; otherwise the
|
||||||
|
// call silently no-ops and JS-triggered navigations (cookie → reload) never fire.
|
||||||
|
const _coerceTimerFn = (fn) => {
|
||||||
|
if (typeof fn === "string") {
|
||||||
|
try { return new Function(fn); } catch (_) { return null; }
|
||||||
|
}
|
||||||
|
return typeof fn === "function" ? fn : null;
|
||||||
|
};
|
||||||
|
|
||||||
globalThis.setTimeout = (fn, delay = 0, ...args) => {
|
globalThis.setTimeout = (fn, delay = 0, ...args) => {
|
||||||
if (typeof fn !== "function") return ++_tid;
|
const f = _coerceTimerFn(fn);
|
||||||
|
if (f === null) return ++_tid;
|
||||||
const id = ++_tid;
|
const id = ++_tid;
|
||||||
_scheduleAfter(delay, () => {
|
_scheduleAfter(delay, () => {
|
||||||
if (_clearedTimers.has(id)) return;
|
if (_clearedTimers.has(id)) return;
|
||||||
try { fn(...args); } catch(e) { console.error("Timer error:", e); }
|
try { f(...args); } catch(e) { console.error("Timer error:", e); }
|
||||||
});
|
});
|
||||||
return id;
|
return id;
|
||||||
};
|
};
|
||||||
@@ -419,12 +431,13 @@ globalThis.setTimeout = (fn, delay = 0, ...args) => {
|
|||||||
globalThis.clearTimeout = (id) => { _clearedTimers.add(id); };
|
globalThis.clearTimeout = (id) => { _clearedTimers.add(id); };
|
||||||
|
|
||||||
globalThis.setInterval = (fn, delay = 0, ...args) => {
|
globalThis.setInterval = (fn, delay = 0, ...args) => {
|
||||||
if (typeof fn !== "function") return ++_tid;
|
const f = _coerceTimerFn(fn);
|
||||||
|
if (f === null) return ++_tid;
|
||||||
const id = ++_tid;
|
const id = ++_tid;
|
||||||
_intervals.add(id);
|
_intervals.add(id);
|
||||||
const tick = () => {
|
const tick = () => {
|
||||||
if (!_intervals.has(id)) return;
|
if (!_intervals.has(id)) return;
|
||||||
try { fn(...args); } catch(e) { console.error("Interval error:", e); }
|
try { f(...args); } catch(e) { console.error("Interval error:", e); }
|
||||||
if (!_intervals.has(id)) return;
|
if (!_intervals.has(id)) return;
|
||||||
_scheduleAfter(delay, tick);
|
_scheduleAfter(delay, tick);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user