Skip to content

Commit 491c881

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

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

chatgpt/duckduckgpt/duckduckgpt.user.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
149149
// @author KudoAI
150150
// @namespace https://kudoai.com
151-
// @version 2025.1.15.8
151+
// @version 2025.1.15.9
152152
// @license MIT
153153
// @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076
154154
// @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076
@@ -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
@@ -3293,7 +3293,8 @@
32933293
// Handle stream done
32943294
let chunk = new TextDecoder('utf8').decode(new Uint8Array(value))
32953295
if (done || chunk.includes(apis[caller.api].watermark)) return handleProcessCompletion()
3296-
this.timeout = setTimeout(handleProcessCompletion, 500) // since reader.read() doesn't signal done in Chromium
3296+
if (env.browser.isChromium) { // clear/add timeout since reader.read() doesn't signal done
3297+
clearTimeout(this.timeout) ; this.timeout = setTimeout(handleProcessCompletion, 500) }
32973298

32983299
// Process/show chunk
32993300
if (caller.api == 'MixerBox AI') { // pre-process chunks
@@ -3332,7 +3333,8 @@
33323333
}
33333334

33343335
function handleProcessCompletion() {
3335-
caller.sender = this.timeout = null
3336+
caller.sender = null
3337+
if (env.browser.isChromium) clearTimeout(this.timeout)
33363338
if (appDiv.querySelector('.loading')) // no text shown
33373339
api.tryNew(caller)
33383340
else { // text was shown

0 commit comments

Comments
 (0)