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);
|
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);
|
|
||||||
})();
|
})();
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user