Skip to content

Commit decd8e0

Browse files
committed
Added Chromium check + clearTimeout() to timeout handling in stream processing ↞ [auto-sync from https://github.com/adamlui/ai-web-extensionss/tree/main/bravegpt]
1 parent 491c881 commit decd8e0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

chatgpt/bravegpt/bravegpt.user.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.15.6
151+
// @version 2025.1.15.7
152152
// @license MIT
153153
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
154154
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
@@ -230,7 +230,7 @@
230230
version: (() => { try { return GM_info.version } catch (err) { return 'unknown' }})()
231231
}
232232
};
233-
['Chrome', 'Firefox', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
233+
['Chromium', 'Firefox', 'Chrome', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
234234
env.browser[`is${ platform == 'Firefox' ? 'FF' : platform }`] = chatgpt.browser['is' + platform]())
235235
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
236236
env.browser.isPhone = env.browser.isMobile && window.innerWidth <= 480
@@ -3409,7 +3409,8 @@
34093409
// Handle stream done
34103410
let chunk = new TextDecoder('utf8').decode(new Uint8Array(value))
34113411
if (done || chunk.includes(apis[caller.api].watermark)) return handleProcessCompletion()
3412-
this.timeout = setTimeout(handleProcessCompletion, 500) // since reader.read() doesn't signal done in Chromium
3412+
if (env.browser.isChromium) { // clear/add timeout since reader.read() doesn't signal done
3413+
clearTimeout(this.timeout) ; this.timeout = setTimeout(handleProcessCompletion, 500) }
34133414

34143415
// Process/show chunk
34153416
if (caller.api == 'MixerBox AI') { // pre-process chunks
@@ -3448,7 +3449,7 @@
34483449
}
34493450

34503451
function handleProcessCompletion() {
3451-
caller.sender = this.timeout = null
3452+
caller.sender = null ; if (env.browser.isChromium) clearTimeout(this.timeout)
34523453
if (appDiv.querySelector('.loading')) // no text shown
34533454
api.tryNew(caller)
34543455
else { // text was shown

0 commit comments

Comments
 (0)