muse-chat-api: Press chat button to refocus Main Chat\n\nUser confirmed pressing the chat button properly refocuses Main Chat.\nSimpler and more reliable than searching for Main chat text in sidebar.
This commit is contained in:
+11
-13
@@ -207,22 +207,20 @@ def cmd_sidechat_use(ws, chat_id):
|
||||
print(f"Navigated to: {result}")
|
||||
|
||||
def cmd_sidechat_main(ws):
|
||||
"""Navigate back to main chat by clicking the Main chat button."""
|
||||
"""Navigate back to main chat by pressing the chat button."""
|
||||
# The chat button (not the sidebar search) properly refocuses Main Chat.
|
||||
# Do NOT navigate to https://muse.ai/ (landing page) - it restores the
|
||||
# last-viewed chat which may be a side chat. Click Main chat instead.
|
||||
# Uses fuzzy matching like cmd_sidechat_use (substring + shortest first).
|
||||
# last-viewed chat which may be a side chat.
|
||||
js = (
|
||||
"(async()=>{"
|
||||
"const ob=[...document.querySelectorAll('button')].find("
|
||||
"b=>b.textContent.includes('Open chat and side chats'));"
|
||||
"if(ob)ob.click();"
|
||||
"await new Promise(r=>setTimeout(r,2000));"
|
||||
"const els=[...document.querySelectorAll('*')];"
|
||||
"const cands=els.filter(e=>e.textContent&&e.textContent.includes('Main chat'));"
|
||||
"cands.sort((a,b)=>a.textContent.length-b.textContent.length);"
|
||||
"const el=cands[0];"
|
||||
"if(!el)return 'NOTFOUND';"
|
||||
"el.click();"
|
||||
# Find the chat button - it refocuses Main Chat when pressed
|
||||
"const btns=[...document.querySelectorAll('button')];"
|
||||
"const chatBtn=btns.find(b=>"
|
||||
"b.textContent.includes('Open chat and side chats')||"
|
||||
"b.getAttribute('aria-label')&&b.getAttribute('aria-label').toLowerCase().includes('chat')"
|
||||
");"
|
||||
"if(!chatBtn)return 'NOBUTTON';"
|
||||
"chatBtn.click();"
|
||||
"await new Promise(r=>setTimeout(r,4000));"
|
||||
"return window.location.href;"
|
||||
"})()"
|
||||
|
||||
Reference in New Issue
Block a user