Skip to content

Commit

Permalink
Added Chromium check + clearTimeout() to timeout handling in stream…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Jan 15, 2025
1 parent 982229d commit b853d01
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions chatgpt/amazongpt/amazongpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @description Adds the magic of AI to Amazon shopping
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.15.5
// @version 2025.1.15.6
// @license MIT
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
Expand Down Expand Up @@ -106,7 +106,7 @@
version: (() => { try { return GM_info.version } catch (err) { return 'unknown' }})()
}
};
['Chrome', 'Firefox', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
['Chromium', 'Firefox', 'Chrome', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
env.browser[`is${ platform == 'Firefox' ? 'FF' : platform }`] = chatgpt.browser['is' + platform]())
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
env.browser.isPhone = env.browser.isMobile && window.innerWidth <= 480
Expand Down Expand Up @@ -2687,7 +2687,8 @@
// Handle stream done
let chunk = new TextDecoder('utf8').decode(new Uint8Array(value))
if (done || chunk.includes(apis[caller.api].watermark)) return handleProcessCompletion()
this.timeout = setTimeout(handleProcessCompletion, 500) // since reader.read() doesn't signal done in Chromium
if (env.browser.isChromium) { // clear/add timeout since reader.read() doesn't signal done
clearTimeout(this.timeout) ; this.timeout = setTimeout(handleProcessCompletion, 500) }

// Process/show chunk
if (caller.api == 'MixerBox AI') { // pre-process chunks
Expand Down Expand Up @@ -2726,7 +2727,7 @@
}

function handleProcessCompletion() {
caller.sender = this.timeout = null
caller.sender = null ; if (env.browser.isChromium) clearTimeout(this.timeout)
if (appDiv.querySelector('.loading')) // no text shown
api.tryNew(caller)
else { // text was shown
Expand Down

0 comments on commit b853d01

Please sign in to comment.