mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2026-06-13 04:04:59 +03:00
Refactor injection logic with tryInject function
This commit is contained in:
+14
-10
@@ -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);
|
||||
})();
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user