From 59e7d23f794c8061143587f3032a00842808f536 Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Mon, 17 Jun 2024 03:01:12 -0700 Subject: [PATCH] Auto-disabled Streaming Mode for Edge users (KudoAI/bravegpt#48) --- bravegpt/greasemonkey/bravegpt.user.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bravegpt/greasemonkey/bravegpt.user.js b/bravegpt/greasemonkey/bravegpt.user.js index bd71fc132a..09b66c9348 100644 --- a/bravegpt/greasemonkey/bravegpt.user.js +++ b/bravegpt/greasemonkey/bravegpt.user.js @@ -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 @@ -184,7 +184,7 @@ 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', @@ -192,7 +192,7 @@ setTimeout(async () => { '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' } @@ -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' }:` + + ` ${msBugLink}`) + } 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' }` + ' Tampermonkey.' @@ -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)) } }