Fix on steam client beta, restart steam instead of reloading tab since that is broken

This commit is contained in:
AAGaming
2022-11-04 21:49:05 -04:00
parent db7bb236d8
commit b44896524f
4 changed files with 29 additions and 24 deletions
+23 -18
View File
@@ -134,15 +134,20 @@ class PluginManager:
await tab.open_websocket() await tab.open_websocket()
await tab.enable() await tab.enable()
await self.inject_javascript(tab, True) await self.inject_javascript(tab, True)
async for msg in tab.listen_for_message(): try:
logger.debug("Page event: " + str(msg.get("method", None))) async for msg in tab.listen_for_message():
if msg.get("method", None) == "Page.domContentEventFired": logger.debug("Page event: " + str(msg.get("method", None)))
if not await tab.has_global_var("deckyHasLoaded", False): if msg.get("method", None) == "Page.domContentEventFired":
await self.inject_javascript(tab) if not await tab.has_global_var("deckyHasLoaded", False):
if msg.get("method", None) == "Inspector.detached": await self.inject_javascript(tab)
logger.info("Steam is exiting...") if msg.get("method", None) == "Inspector.detached":
await tab.close_websocket() logger.info("Steam is exiting...")
break await tab.close_websocket()
break
except Exception as e:
logger.error("Exception while reading page events " + format_exc())
await tab.close_websocket()
pass
# while True: # while True:
# await sleep(5) # await sleep(5)
# if not await tab.has_global_var("deckyHasLoaded", False): # if not await tab.has_global_var("deckyHasLoaded", False):
@@ -152,15 +157,15 @@ class PluginManager:
async def inject_javascript(self, tab: Tab, first=False, request=None): async def inject_javascript(self, tab: Tab, first=False, request=None):
logger.info("Loading Decky frontend!") logger.info("Loading Decky frontend!")
try: try:
if first: # if first:
if await tab.has_global_var("deckyHasLoaded", False): # if await tab.has_global_var("deckyHasLoaded", False):
tabs = await get_tabs() # tabs = await get_tabs()
for t in tabs: # for t in tabs:
if t.title != "Steam" and t.title != "SP": # if t.title != "Steam" and t.title != "SP":
logger.debug("Closing tab: " + getattr(t, "title", "Untitled")) # logger.debug("Closing tab: " + getattr(t, "title", "Untitled"))
await t.close() # await t.close()
await sleep(0.5) # await sleep(0.5)
await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => location.reload(), 1000)}window.deckyHasLoaded = true;(async()=>{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')})();}catch(e){console.error(e)}", False, False, False) await tab.evaluate_js("try{if (window.deckyHasLoaded){setTimeout(() => SteamClient.User.StartRestart(), 100)}else{window.deckyHasLoaded = true;(async()=>{while(!window.SP_REACT){await new Promise(r => setTimeout(r, 10))};await import('http://localhost:1337/frontend/index.js')})();}}catch(e){console.error(e)}", False, False, False)
except: except:
logger.info("Failed to inject JavaScript into tab\n" + format_exc()) logger.info("Failed to inject JavaScript into tab\n" + format_exc())
pass pass
+1 -1
View File
@@ -261,5 +261,5 @@ class Utilities:
self.logger.info("Disabling React DevTools") self.logger.info("Disabling React DevTools")
tab = await get_gamepadui_tab() tab = await get_gamepadui_tab()
self.rdt_script_id = None self.rdt_script_id = None
await tab.evaluate_js("location.reload();", False, True, False) await tab.evaluate_js("SteamClient.User.StartRestart();", False, True, False)
self.logger.info("React DevTools disabled") self.logger.info("React DevTools disabled")
+1 -1
View File
@@ -41,7 +41,7 @@
} }
}, },
"dependencies": { "dependencies": {
"decky-frontend-lib": "^3.7.12", "decky-frontend-lib": "^3.7.14",
"react-file-icon": "^1.2.0", "react-file-icon": "^1.2.0",
"react-icons": "^4.4.0", "react-icons": "^4.4.0",
"react-markdown": "^8.0.3", "react-markdown": "^8.0.3",
+4 -4
View File
@@ -10,7 +10,7 @@ specifiers:
'@types/react-file-icon': ^1.0.1 '@types/react-file-icon': ^1.0.1
'@types/react-router': 5.1.18 '@types/react-router': 5.1.18
'@types/webpack': ^5.28.0 '@types/webpack': ^5.28.0
decky-frontend-lib: ^3.7.12 decky-frontend-lib: ^3.7.14
husky: ^8.0.1 husky: ^8.0.1
import-sort-style-module: ^6.0.0 import-sort-style-module: ^6.0.0
inquirer: ^8.2.4 inquirer: ^8.2.4
@@ -30,7 +30,7 @@ specifiers:
typescript: ^4.7.4 typescript: ^4.7.4
dependencies: dependencies:
decky-frontend-lib: 3.7.12 decky-frontend-lib: 3.7.14
react-file-icon: 1.2.0_wcqkhtmu7mswc6yz4uyexck3ty react-file-icon: 1.2.0_wcqkhtmu7mswc6yz4uyexck3ty
react-icons: 4.4.0_react@16.14.0 react-icons: 4.4.0_react@16.14.0
react-markdown: 8.0.3_vshvapmxg47tngu7tvrsqpq55u react-markdown: 8.0.3_vshvapmxg47tngu7tvrsqpq55u
@@ -944,8 +944,8 @@ packages:
dependencies: dependencies:
ms: 2.1.2 ms: 2.1.2
/decky-frontend-lib/3.7.12: /decky-frontend-lib/3.7.14:
resolution: {integrity: sha512-whDV9zHuEBFj17zKoT51aRcUxLvSzBNu2lc242/EO9aFFP064FVCrJu+r7CxWe0hlQ7sA4FKX1qgCwsZ6H+PZg==} resolution: {integrity: sha512-ShAoP3VqiwkJYukDBHsOF9fk7wYw0VaKpHw6j9WdzLxwZwBcg0J7QBNIFYP3nfA0UgEwSJVEg/22kONiplipmA==}
dev: false dev: false
/decode-named-character-reference/1.0.2: /decode-named-character-reference/1.0.2: