MCPcopy
hub / github.com/theajack/disable-devtool / initInterval

Function initInterval

src/utils/interval.ts:19–42  ·  view source on GitHub ↗
(dd: IDisableDevtool)

Source from the content-addressed store, hash-verified

17let time = 0;
18
19export function initInterval (dd: IDisableDevtool) {
20 let _pause = false;
21 const pause = () => {_pause = true;};
22 const goon = () => {_pause = false;};
23 hackAlert(pause, goon); // 防止 alert等方法触发了debug延迟计算
24 onPageShowHide(goon, pause); // 防止切后台触发了debug延迟计算
25
26 interval = window.setInterval(() => {
27 if (dd.isSuspend || _pause || isIgnored()) return;
28 for (const detector of calls) {
29 clearDevToolOpenState(detector.type);
30 detector.detect(time++);
31 };
32 clearLog();
33 checkOnDevClose();
34 }, config.interval);
35 // stopIntervalTime 之后判断 如果不是pc去掉定时器interval,为了优化移动端的性能
36 // 如果控制面板被打开了该定时器timer会被清除
37 timer = setTimeout(() => {
38 if (!IS.pc && !DebugLib.isUsing()) {
39 clearDDInterval();
40 }
41 }, config.stopIntervalTime);
42}
43
44export function registInterval (detector: Detector) {
45 calls.push(detector);

Callers 1

main.tsFile · 0.90

Calls 9

hackAlertFunction · 0.90
onPageShowHideFunction · 0.90
isIgnoredFunction · 0.90
clearDevToolOpenStateFunction · 0.90
clearLogFunction · 0.90
checkOnDevCloseFunction · 0.90
clearDDIntervalFunction · 0.85
isUsingMethod · 0.80
detectMethod · 0.45

Tested by

no test coverage detected