From 4f552c5b3cd0421c80c3ea8006052fa3a2614406 Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Mon, 8 Jun 2026 03:07:27 -0700 Subject: [PATCH] Refactor injection logic with tryInject function --- NSLGameScanner.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/NSLGameScanner.py b/NSLGameScanner.py index 2fd20dd..f5ebbbc 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -3690,21 +3690,25 @@ SCANNER_CODE = r""" parent.appendChild(wrapper); }; - let attempts = 0; - const interval = setInterval(() => { - + const tryInject = () => { const target = isGameMode() ? findGameModeTarget() : findDesktopTarget(); - if (target) { - inject(target); - clearInterval(interval); - } else if (++attempts > 20) { - clearInterval(interval); - } + if (target) inject(target); + }; + + tryInject(); + + const observer = new MutationObserver(() => { + tryInject(); + }); + + observer.observe(document.body, { + childList: true, + subtree: true + }); - }, 500); })(); """