muse-chat-api: Use fuzzy matching for Main chat button\n\nExact match was too fragile - if the UI text differs slightly,\nit returns NOTFOUND and the browser stays on the side chat.\nNow uses substring + shortest-first like cmd_sidechat_use.
This commit is contained in:
@@ -210,6 +210,7 @@ def cmd_sidechat_main(ws):
|
||||
"""Navigate back to main chat by clicking the Main chat button."""
|
||||
# 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).
|
||||
js = (
|
||||
"(async()=>{"
|
||||
"const ob=[...document.querySelectorAll('button')].find("
|
||||
@@ -217,7 +218,8 @@ def cmd_sidechat_main(ws):
|
||||
"if(ob)ob.click();"
|
||||
"await new Promise(r=>setTimeout(r,2000));"
|
||||
"const els=[...document.querySelectorAll('*')];"
|
||||
"const cands=els.filter(e=>e.textContent&&e.textContent.trim()==='Main chat');"
|
||||
"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();"
|
||||
|
||||
Reference in New Issue
Block a user