@tomflow/chatloop-extension 0.3.75 → 0.3.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,11 +36,18 @@ async function newChatReady(id){
|
|
|
36
36
|
||mains.length!==1||!visible(editor)
|
|
37
37
|
||mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]'))
|
|
38
38
|
return false;
|
|
39
|
+
// A visible account-switch notice invalidates the first-send
|
|
40
|
+
// environment. Catch it before any editor mutation or send click.
|
|
41
|
+
const switched=/你的账户已切换[。.!!\s]*请重新发送消息|your account (?:has been |was )?switched[.!\s]*please (?:re-?send|send again) (?:your )?message/i;
|
|
42
|
+
if(switched.test(mains[0].innerText||mains[0].textContent||''))
|
|
43
|
+
return 'START_ACCOUNT_SWITCH_VISIBLE';
|
|
39
44
|
return (editor.innerText||editor.textContent||'').trim()
|
|
40
45
|
?'START_COMPOSER_NOT_EMPTY':true;
|
|
41
46
|
}}),Math.min(1500,deadline-Date.now()));
|
|
42
47
|
if(result?.[0]?.result==='START_COMPOSER_NOT_EMPTY')
|
|
43
48
|
throw Error('START_COMPOSER_NOT_EMPTY');
|
|
49
|
+
if(result?.[0]?.result==='START_ACCOUNT_SWITCH_VISIBLE')
|
|
50
|
+
throw Error('START_ACCOUNT_SWITCH_VISIBLE');
|
|
44
51
|
if(result?.[0]?.result===true)return;
|
|
45
52
|
}
|
|
46
53
|
await pause(Math.min(420,Math.max(1,deadline-Date.now())));
|
|
@@ -73,6 +80,11 @@ async function sendFirst(id,text){
|
|
|
73
80
|
||(editor.innerText||editor.textContent||'').trim()
|
|
74
81
|
||mains[0].querySelector('[data-chatgpt-search-message-ids],[data-message-author-role]'))
|
|
75
82
|
throw Error('START_COMPOSER_UNVERIFIED');
|
|
83
|
+
// Recheck immediately before changing the composer; account
|
|
84
|
+
// identity may have switched after the initial readiness probe.
|
|
85
|
+
const switched=/你的账户已切换[。.!!\s]*请重新发送消息|your account (?:has been |was )?switched[.!\s]*please (?:re-?send|send again) (?:your )?message/i;
|
|
86
|
+
if(switched.test(mains[0].innerText||mains[0].textContent||''))
|
|
87
|
+
throw Error('START_ACCOUNT_SWITCH_VISIBLE');
|
|
76
88
|
const canonical=v=>String(v||'').replace(/\s+/g,'');
|
|
77
89
|
editor.focus();
|
|
78
90
|
if(!document.execCommand('insertText',false,instruction))throw Error('START_INPUT_REJECTED');
|
|
@@ -222,8 +234,8 @@ async function run(){
|
|
|
222
234
|
// This is diagnostics only; it does NOT authorize a retry or prove a
|
|
223
235
|
// message was never sent. Keep the existing fail-closed Owner semantics.
|
|
224
236
|
const failureCode=['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
225
|
-
'START_COMPOSER_NOT_EMPTY','
|
|
226
|
-
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
237
|
+
'START_COMPOSER_NOT_EMPTY','START_ACCOUNT_SWITCH_VISIBLE',
|
|
238
|
+
'FIRST_TURN_OBSERVER_UNAVAILABLE','START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
227
239
|
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
228
240
|
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
229
241
|
.includes(e.message) ? e.message : null;
|
package/extension/background.js
CHANGED
|
@@ -496,8 +496,8 @@ async function sessionStartResult(message,sender){
|
|
|
496
496
|
lastStartActionTabId:sender.tab.id,
|
|
497
497
|
reason:confirmed?'':adopted?'ADOPTION_UNVERIFIED':'START_SEND_UNVERIFIED',
|
|
498
498
|
...(!confirmed&&['START_HOME_URL_UNVERIFIED','NEW_CHAT_NOT_READY',
|
|
499
|
-
'START_COMPOSER_NOT_EMPTY','
|
|
500
|
-
'START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
499
|
+
'START_COMPOSER_NOT_EMPTY','START_ACCOUNT_SWITCH_VISIBLE',
|
|
500
|
+
'FIRST_TURN_OBSERVER_UNAVAILABLE','START_SEND_BUTTON_UNAVAILABLE','START_INPUT_CHANGED',
|
|
501
501
|
'START_INPUT_UNVERIFIED','START_INPUT_REJECTED',
|
|
502
502
|
'START_CLICK_UNVERIFIED','FIRST_SEND_RECEIPT_UNKNOWN']
|
|
503
503
|
.includes(message.failureCode)
|
package/extension/manifest.json
CHANGED