Skip to content

Commit

Permalink
Shortened env.userscriptManager to env.scriptManager ↞ [auto-sync…
Browse files Browse the repository at this point in the history
… from `adamlui/chatgpt-apps`]
  • Loading branch information
adamlui authored and kudo-sync-bot committed Sep 15, 2024
1 parent 4570ebb commit 9f8106b
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions greasemonkey/bravegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2024.9.14.3
// @version 2024.9.14.4
// @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 @@ -238,7 +238,7 @@
.replace(/(\d+)-?([a-zA-Z-]*)$/, (_, id, name) => `${id}/${ !name ? 'script' : name }.meta.js`)

// Init ENV info
const env = { browser: {}, userscriptManager: (() => { try { return GM_info.scriptHandler } catch (err) { return 'other' }})() };
const env = { browser: {}, scriptManager: (() => { try { return GM_info.scriptHandler } catch (err) { return 'other' }})() };
['Chrome', 'Firefox', 'Edge', 'Brave', 'Mobile'].forEach(platform =>
env.browser['is' + platform] = chatgpt.browser['is' + platform]())
env.browser.isPortrait = env.browser.isMobile && (window.innerWidth < window.innerHeight)
Expand Down Expand Up @@ -307,8 +307,8 @@
// Init COMPATIBILITY flags
log.debug('Initializing compatibility flags...')
const streamingSupported = {
browser: !(env.userscriptManager == 'Tampermonkey' && (env.browser.isChrome || env.browser.isEdge || env.browser.isBrave)),
userscriptManager: /Tampermonkey|ScriptCat/.test(env.userscriptManager) }
browser: !(env.scriptManager == 'Tampermonkey' && (env.browser.isChrome || env.browser.isEdge || env.browser.isBrave)),
scriptManager: /Tampermonkey|ScriptCat/.test(env.scriptManager) }
log.debug(`Success! streamingSupported = ${log.prettifyObj(streamingSupported)}`)

// Init CONFIG
Expand All @@ -321,7 +321,7 @@
'rqDisabled', 'scheme', 'stickySidebar', 'streamingDisabled', 'suffixEnabled', 'widerSidebar')
if (!config.replyLanguage) settings.save('replyLanguage', config.userLanguage) // init reply language if unset
if (!config.fontSize) settings.save('fontSize', 16) // init reply font size if unset
if (!streamingSupported.browser || !streamingSupported.userscriptManager) settings.save('streamingDisabled', true) // disable Streaming in unspported env
if (!streamingSupported.browser || !streamingSupported.scriptManager) settings.save('streamingDisabled', true) // disable Streaming in unspported env
log.debug(`Success! config = ${log.prettifyObj(config)}`)

// Init API props
Expand Down Expand Up @@ -379,8 +379,8 @@

// Init XHR fetcher
log.debug('Initializing XHR fetcher...')
const xhr = env.userscriptManager == 'OrangeMonkey' ? GM_xmlhttpRequest : GM.xmlHttpRequest
log.debug(`Success! xhr = ${ env.userscriptManager == 'OrangeMonkey' ? 'GM_xmlhttpRequest' : 'GM.xmlHttpRequest' }`)
const xhr = env.scriptManager == 'OrangeMonkey' ? GM_xmlhttpRequest : GM.xmlHttpRequest
log.debug(`Success! xhr = ${ env.scriptManager == 'OrangeMonkey' ? 'GM_xmlhttpRequest' : 'GM.xmlHttpRequest' }`)

// Init localized MESSAGES
log.debug('Initializing localized messages...')
Expand Down Expand Up @@ -468,7 +468,7 @@
log.debug('Initializing menu objects...')
const menuIDs = [] // to store registered cmds for removal while preserving order
const menuState = {
symbol: ['❌', '✔️'], separator: env.userscriptManager == 'Tampermonkey' ? ' — ' : ': ',
symbol: ['❌', '✔️'], separator: env.scriptManager == 'Tampermonkey' ? ' — ' : ': ',
word: [(msgs.state_off || 'Off').toUpperCase(), (msgs.state_on || 'On').toUpperCase()]
}
log.debug(`Success! menuState = ${log.prettifyObj(menuState)}`)
Expand Down Expand Up @@ -499,7 +499,7 @@
function refreshMenu() {
log.caller = 'refreshMenu()'
log.debug('Refreshing toolbar menu...')
if (env.userscriptManager == 'OrangeMonkey') { log.debug('OrangeMonkey userscript manager unsupported.') ; return }
if (env.scriptManager == 'OrangeMonkey') { log.debug('OrangeMonkey userscript manager unsupported.') ; return }
for (const id of menuIDs) { GM_unregisterMenuCommand(id) } registerMenu()
log.debug('Success! Menu refreshed')
}
Expand Down Expand Up @@ -1071,7 +1071,7 @@
// Add click listener
settingItem.onclick = () => {
if (!(key == 'streamingDisabled' // visually switch toggle if not Streaminng...
&& (!streamingSupported.browser || !streamingSupported.userscriptManager // ...in unsupported env...
&& (!streamingSupported.browser || !streamingSupported.scriptManager // ...in unsupported env...
|| !config.proxyAPIenabled) // ...or in OpenAI mode
)) modals.settings.toggle.switch(settingToggle)

Expand Down Expand Up @@ -2688,8 +2688,8 @@
const scriptCatLink = env.browser.isFirefox ? 'https://addons.mozilla.org/firefox/addon/scriptcat/'
: env.browser.isEdge ? 'https://microsoftedge.microsoft.com/addons/detail/scriptcat/liilgpjgabokdklappibcjfablkpcekh'
: 'https://chromewebstore.google.com/detail/scriptcat/ndcooeababalnlpkfedmmbbbgkljhpjf'
if (!streamingSupported.userscriptManager) { // alert userscript manager unsupported, suggest TM/SC
log.debug(`Streaming Mode unsupported in ${env.userscriptManager}`)
if (!streamingSupported.scriptManager) { // alert userscript manager unsupported, suggest TM/SC
log.debug(`Streaming Mode unsupported in ${env.scriptManager}`)
const suggestAlertID = siteAlert(`${settingsProps.streamingDisabled.label} ${ msgs.alert_unavailable || 'unavailable' }`,
`${settingsProps.streamingDisabled.label} ${ msgs.alert_isOnlyAvailFor || 'is only available for' }`
+ ( !env.browser.isEdge && !env.browser.isBrave ? // suggest TM for supported browsers
Expand Down Expand Up @@ -2771,7 +2771,7 @@
log.caller = 'session.deleteOpenAIcookies()'
log.debug('Deleting OpenAI cookies...')
GM_deleteValue(app.configKeyPrefix + '_openAItoken')
if (env.userscriptManager != 'Tampermonkey') return
if (env.scriptManager != 'Tampermonkey') return
GM_cookie.list({ url: apis.OpenAI.endpoints.auth }, (cookies, error) => {
if (!error) { for (const cookie of cookies) {
GM_cookie.delete({ url: apis.OpenAI.endpoints.auth, name: cookie.name })
Expand Down

0 comments on commit 9f8106b

Please sign in to comment.