Skip to content

Commit b853d01

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/amazongpt]
1 parent 982229d commit b853d01

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

chatgpt/amazongpt/amazongpt.user.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @description Adds the magic of AI to Amazon shopping
44
// @author KudoAI
55
// @namespace https://kudoai.com
6-
// @version 2025.1.15.5
6+
// @version 2025.1.15.6
77
// @license MIT
88
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
99
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
@@ -106,7 +106,7 @@
106106
version: (() => { try { return GM_info.version } catch (err) { return 'unknown' }})()
107107
}
108108
};
109-
['Chrome', 'Firefox', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
109+
['Chromium', 'Firefox', 'Chrome', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
110110
env.browser[`is${ platform == 'Firefox' ? 'FF' : platform }`] = chatgpt.browser['is' + platform]())
111111
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
112112
env.browser.isPhone = env.browser.isMobile && window.innerWidth <= 480
@@ -2687,7 +2687,8 @@
26872687
// Handle stream done
26882688
let chunk = new TextDecoder('utf8').decode(new Uint8Array(value))
26892689
if (done || chunk.includes(apis[caller.api].watermark)) return handleProcessCompletion()
2690-
this.timeout = setTimeout(handleProcessCompletion, 500) // since reader.read() doesn't signal done in Chromium
2690+
if (env.browser.isChromium) { // clear/add timeout since reader.read() doesn't signal done
2691+
clearTimeout(this.timeout) ; this.timeout = setTimeout(handleProcessCompletion, 500) }
26912692

26922693
// Process/show chunk
26932694
if (caller.api == 'MixerBox AI') { // pre-process chunks
@@ -2726,7 +2727,7 @@
27262727
}
27272728

27282729
function handleProcessCompletion() {
2729-
caller.sender = this.timeout = null
2730+
caller.sender = null ; if (env.browser.isChromium) clearTimeout(this.timeout)
27302731
if (appDiv.querySelector('.loading')) // no text shown
27312732
api.tryNew(caller)
27322733
else { // text was shown

0 commit comments

Comments
 (0)