Skip to content

Commit

Permalink
Renamed settings.props to more semantic settings.controls ↞ [auto…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Nov 20, 2024
1 parent 40f3b24 commit 24d8398
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions greasemonkey/duckduckgpt.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-DuckDuckGo (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2024.11.20.1
// @version 2024.11.20.2
// @license MIT
// @icon https://media.ddgpt.com/images/icons/duckduckgpt/icon48.png?af89302
// @icon64 https://media.ddgpt.com/images/icons/duckduckgpt/icon64.png?af89302
Expand Down Expand Up @@ -538,9 +538,9 @@
}
log.debug(`Success! app.msgs = ${log.prettifyObj(app.msgs)}`)

// Init SETTINGS props
// Init SETTINGS controls
log.debug('Initializing settings properties...')
Object.assign(settings, { props: {
Object.assign(settings, { controls: {
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses',
label: app.msgs.menuLabel_proxyAPImode,
helptip: app.msgs.helptip_proxyAPImode },
Expand Down Expand Up @@ -592,7 +592,7 @@
about: { type: 'modal', icon: 'questionMarkCircle',
label: `${app.msgs.menuLabel_about} ${app.name}...` }
}})
log.debug(`Success! settings.props = ${log.prettifyObj(settings.props)}`)
log.debug(`Success! settings.controls = ${log.prettifyObj(settings.controls)}`)

// Init ALERTS
Object.assign(app, { alerts: {
Expand All @@ -619,12 +619,12 @@

// Add Proxy API Mode toggle
const pmLabel = menu.state.symbols[+config.proxyAPIenabled] + ' '
+ settings.props.proxyAPIenabled.label + ' '
+ settings.controls.proxyAPIenabled.label + ' '
+ menu.state.separator + menu.state.words[+config.proxyAPIenabled]
menu.ids.push(GM_registerMenuCommand(pmLabel, toggle.proxyMode))

// Add About entry
const aboutLabel = `💡 ${settings.props.about.label}`
const aboutLabel = `💡 ${settings.controls.about.label}`
menu.ids.push(GM_registerMenuCommand(aboutLabel, modals.about.show))

// Add Settings entry
Expand Down Expand Up @@ -790,9 +790,9 @@

// Append notif type icon
const iconStyles = 'width: 28px ; height: 28px ; position: relative ; top: 3.5px ; margin-left: 11px ;',
mode = Object.keys(settings.props).find(key => settings.props[key].label.includes(msg.trim()))
mode = Object.keys(settings.controls).find(key => settings.controls[key].label.includes(msg.trim()))
if (mode && !/(?:pre|suf)fix/.test(mode)) {
const modeIcon = icons[settings.props[mode].icon].create()
const modeIcon = icons[settings.controls[mode].icon].create()
modeIcon.style.cssText = iconStyles
+ ( /autoget|debug|focus|scroll/i.test(mode) ? 'top: 0.5px' : '' ) // raise some icons
+ ( /animation|debug/i.test(mode) ? 'width: 23px ; height: 23px' : '' ) // shrink some icon
Expand Down Expand Up @@ -1109,8 +1109,8 @@

// Init settings keys
log.debug('Initializing settings keys...')
const settingsKeys = Object.keys(settings.props).filter(key => !(env.browser.isMobile && settings.props[key].mobile == false)
&& !(ui.site.isCentered && settings.props[key].centered == false))
const settingsKeys = Object.keys(settings.controls).filter(key => !(env.browser.isMobile && settings.controls[key].mobile == false)
&& !(ui.site.isCentered && settings.controls[key].centered == false))
log.debug(`Success! settingsKeys = ${log.prettifyObj(settingsKeys)}`)

// Init logo
Expand Down Expand Up @@ -1142,7 +1142,7 @@

// Create/append setting icons/labels/toggles
settingsKeys.forEach((key, idx) => {
const setting = settings.props[key]
const setting = settings.controls[key]

// Create/append item/label elems
const settingItem = document.createElement('li') ; settingItem.id = key + '-menu-entry'
Expand Down Expand Up @@ -1229,7 +1229,7 @@
log.caller = 'settings.createAppend()'
log.debug(`Toggling ${settingItem.textContent} ${ key.includes('Disabled') ^ config[key] ? 'OFF' : 'ON' }...`)
settings.save(key, !config[key]) // update config
notify(`${settings.props[key].label} ${menu.state.words[+(key.includes('Disabled') ^ config[key])]}`)
notify(`${settings.controls[key].label} ${menu.state.words[+(key.includes('Disabled') ^ config[key])]}`)
log[key.includes('debug') ? 'info' : 'debug'](`Success! config.${key} = ${config[key]}`)
}
}
Expand Down Expand Up @@ -2552,7 +2552,7 @@
}
log.caller = `toggle.animations('${layer}')`
log.debug(`Success! ${layer.toUpperCase()} animations toggled ${ config[configKey] ? 'OFF' : 'ON' }`)
notify(`${settings.props[layer + 'AnimationsDisabled'].label} ${menu.state.words[+!config[layer + 'AnimationsDisabled']]}`)
notify(`${settings.controls[layer + 'AnimationsDisabled'].label} ${menu.state.words[+!config[layer + 'AnimationsDisabled']]}`)
},

autoGet() {
Expand All @@ -2563,7 +2563,7 @@
if (config.autoGet) // disable Prefix/Suffix mode if enabled
['prefix', 'suffix'].forEach(manualMode => {
if (config[manualMode + 'Enabled']) toggle.manualGet(manualMode) })
notify(`${settings.props.autoGet.label} ${menu.state.words[+config.autoGet]}`)
notify(`${settings.controls.autoGet.label} ${menu.state.words[+config.autoGet]}`)
if (modals.settings.get()) { // update visual state of Settings toggle
const autoGetToggle = document.querySelector('[id*="autoGet"][id*="menu-entry"] input')
if (autoGetToggle.checked != config.autoGet) modals.settings.toggle.switch(autoGetToggle)
Expand Down Expand Up @@ -2605,7 +2605,7 @@
log.debug(`Toggling ${log.toTitleCase(mode)} Mode ${ config[modeKey] ? 'OFF' : 'ON' }...`)
settings.save(modeKey, !config[modeKey])
if (config[modeKey] && config.autoGet) toggle.autoGet() // disable Auto-Get mode if enabled
notify(`${settings.props[modeKey].label} ${menu.state.words[+config[modeKey]]}`)
notify(`${settings.controls[modeKey].label} ${menu.state.words[+config[modeKey]]}`)
if (modals.settings.get()) { // update visual state of Settings toggle
const modeToggle = document.querySelector(`[id*="${modeKey}"][id*="menu-entry"] input`)
if (modeToggle.checked != config[modeKey]) modals.settings.toggle.switch(modeToggle)
Expand Down Expand Up @@ -2699,8 +2699,8 @@
: 'https://chromewebstore.google.com/detail/scriptcat/ndcooeababalnlpkfedmmbbbgkljhpjf'
if (!streamingSupported.scriptManager) { // alert userscript manager unsupported, suggest TM/SC
log.debug(`Streaming Mode unsupported in ${env.scriptManager}`)
const suggestAlertID = siteAlert(`${settings.props.streamingDisabled.label} ${app.msgs.alert_unavailable}`,
`${settings.props.streamingDisabled.label} ${app.msgs.alert_isOnlyAvailFor}`
const suggestAlertID = siteAlert(`${settings.controls.streamingDisabled.label} ${app.msgs.alert_unavailable}`,
`${settings.controls.streamingDisabled.label} ${app.msgs.alert_isOnlyAvailFor}`
+ ( !env.browser.isEdge && !env.browser.isBrave ? // suggest TM for supported browsers
` <a target="_blank" rel="noopener" href="https://tampermonkey.net">Tampermonkey</a> ${app.msgs.alert_and}`
: '' )
Expand All @@ -2711,8 +2711,8 @@
modals.init(suggestAlert) // add classes/stars, disable wheel-scrolling, dim bg, glowup btns
} else if (!streamingSupported.browser) { // alert TM/browser unsupported, suggest SC
log.debug('Streaming Mode unsupported in browser')
const suggestAlertID = siteAlert(`${settings.props.streamingDisabled.label} ${app.msgs.alert_unavailable}`,
`${settings.props.streamingDisabled.label} ${app.msgs.alert_isUnsupportedIn} `
const suggestAlertID = siteAlert(`${settings.controls.streamingDisabled.label} ${app.msgs.alert_unavailable}`,
`${settings.controls.streamingDisabled.label} ${app.msgs.alert_isUnsupportedIn} `
+ `${ env.browser.isChrome ? 'Chrome' : env.browser.isEdge ? 'Edge' : 'Brave' } ${app.msgs.alert_whenUsing} Tampermonkey. `
+ `${app.msgs.alert_pleaseUse} <a target="_blank" rel="noopener" href="${scriptCatLink}">ScriptCat</a> `
+ `${app.msgs.alert_instead}.`
Expand All @@ -2721,7 +2721,7 @@
modals.init(suggestAlert) // add classes/stars, disable wheel-scrolling, dim bg, glowup btns
} else if (!config.proxyAPIenabled) { // alert OpenAI API unsupported, suggest Proxy Mode
log.debug('Streaming Mode unsupported in OpenAI mode')
let msg = `${settings.props.streamingDisabled.label} `
let msg = `${settings.controls.streamingDisabled.label} `
+ `${app.msgs.alert_isCurrentlyOnlyAvailBy} `
+ `${app.msgs.alert_switchingOn} ${app.msgs.mode_proxy}. `
+ `(${app.msgs.alert_openAIsupportSoon}!)`
Expand All @@ -2734,7 +2734,7 @@
} else { // functional toggle
log.debug(`Toggling Streaming Mode ${ config.streamingDisabled ? 'ON' : 'OFF' }`)
settings.save('streamingDisabled', !config.streamingDisabled)
notify(`${settings.props.streamingDisabled.label} ${menu.state.words[+!config.streamingDisabled]}`)
notify(`${settings.controls.streamingDisabled.label} ${menu.state.words[+!config.streamingDisabled]}`)
log.debug(`Success! config.streamingDisabled = ${config.streamingDisabled}`)
}
},
Expand Down

0 comments on commit 24d8398

Please sign in to comment.