Skip to content

Commit

Permalink
Auto-disabled Streaming Mode for Edge users (KudoAI/bravegpt#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Jun 17, 2024
1 parent 7568ee4 commit 59e7d23
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bravegpt/greasemonkey/bravegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
// @description:zu Engeza amaswazi aseChatGPT emugqa wokuqala weBrave Search (ibhulohwe nguGPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2024.6.17.1
// @version 2024.6.17.2
// @license MIT
// @icon https://media.bravegpt.com/images/icons/bravegpt/icon48.png?0a9e287
// @icon64 https://media.bravegpt.com/images/icons/bravegpt/icon64.png?0a9e287
Expand Down Expand Up @@ -184,15 +184,15 @@ setTimeout(async () => {
.replace(/(\d+)-?([a-zA-Z-]*)$/, (_, id, name) => `${ id }/${ !name ? 'script' : name }.meta.js`)
config.supportURL = config.gitHubURL + '/issues/new'
config.feedbackURL = config.gitHubURL + '/discussions/new/choose'
config.assetHostURL = config.gitHubURL.replace('github.com', 'cdn.jsdelivr.net/gh') + '@5814342/'
config.assetHostURL = config.gitHubURL.replace('github.com', 'cdn.jsdelivr.net/gh') + '@bb63c4e/'
config.userLanguage = chatgpt.getUserLanguage()
config.userLocale = config.userLanguage.includes('-') ? config.userLanguage.split('-')[1].toLowerCase() : ''
loadSetting('autoGetDisabled', 'autoFocusChatbarDisabled', 'autoScroll', 'fontSize', 'prefixEnabled',
'proxyAPIenabled', 'replyLanguage', 'rqDisabled', 'scheme', 'streamingDisabled',
'suffixEnabled', 'widerSidebar')
if (!config.replyLanguage) saveSetting('replyLanguage', config.userLanguage) // init reply language if unset
if (!config.fontSize) saveSetting('fontSize', 16) // init reply font size if unset
if (getUserscriptManager() != 'Tampermonkey') saveSetting('streamingDisabled', true) // disable streaming if not TM
if (isEdge || getUserscriptManager() != 'Tampermonkey') saveSetting('streamingDisabled', true) // disable streaming if Edge or not TM

// Init API props
const openAIendpoints = { auth: 'https://auth0.openai.com', session: 'https://chatgpt.com/api/auth/session' }
Expand Down Expand Up @@ -231,7 +231,14 @@ setTimeout(async () => {
+ ( msgs.mode_streaming || 'Streaming Mode' ) + ' '
+ state.separator + state.word[+stmState]
menuIDs.push(GM_registerMenuCommand(stmLabel, () => {
if (getUserscriptManager() != 'Tampermonkey') // alert userscript manager unsupported, suggest Tampermonkey
if (isEdge) { // alert Edge unsupported, link to browser bug
const msBugLink = 'https://answers.microsoft.com/en-us/microsoftedge/forum/all/'
+ 'status-access-violation-issues/1fd4a2ef-6736-441f-8421-6ed167105093'
siteAlert(`${ msgs.mode_streaming || 'Streaming Mode' } ${ msgs.alert_unavailable || 'unavailable' }`,
`${ msgs.mode_streaming || 'Streaming Mode' } ${ msgs.alert_isUnsupportedIn || 'is unsupported in' } Edge`
+ ` ${ msgs.alert_untilMSfixesBug || 'until Microsoft fixes this long-standing browser rendering bug' }:`
+ ` <a target="_blank" rel="noopener" href="${msBugLink}">${msBugLink}</a>`)
} else if (getUserscriptManager() != 'Tampermonkey') // alert userscript manager unsupported, suggest Tampermonkey
siteAlert(`${ msgs.mode_streaming || 'Streaming Mode' } ${ msgs.alert_unavailable || 'unavailable' }`,
`${ msgs.mode_streaming || 'Streaming Mode' } ${ msgs.alert_isOnlyAvailFor || 'is only available for' }`
+ ' <a target="_blank" rel="noopener" href="https://tampermonkey.net">Tampermonkey</a>.'
Expand Down Expand Up @@ -1382,7 +1389,7 @@ setTimeout(async () => {
} catch (err) { consoleErr('Error showing stream', err.message) }
return reader.read().then(({ done, value }) => {
if (get.reply.sender == caller.api) // am designated sender, recurse
setTimeout(() => { processStreamText({ done, value }) }, isEdge ? 200 : 1) // Edge delay vs. STATUS_ACCESS_VIOLATION bug
processStreamText({ done, value })
}).catch(err => consoleErr('Error reading stream', err.message))
}
}
Expand Down

0 comments on commit 59e7d23

Please sign in to comment.