Refactor injection logic with tryInject function

This commit is contained in:
Roy
2026-06-08 03:07:27 -07:00
committed by GitHub
parent 579cdfdef0
commit 4f552c5b3c
+14 -10
View File
@@ -3690,21 +3690,25 @@ SCANNER_CODE = r"""
parent.appendChild(wrapper); parent.appendChild(wrapper);
}; };
let attempts = 0; const tryInject = () => {
const interval = setInterval(() => {
const target = isGameMode() const target = isGameMode()
? findGameModeTarget() ? findGameModeTarget()
: findDesktopTarget(); : findDesktopTarget();
if (target) { if (target) inject(target);
inject(target); };
clearInterval(interval);
} else if (++attempts > 20) { tryInject();
clearInterval(interval);
} const observer = new MutationObserver(() => {
tryInject();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}, 500);
})(); })();
""" """