|
148 | 148 | // @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
|
149 | 149 | // @author KudoAI
|
150 | 150 | // @namespace https://kudoai.com
|
151 |
| -// @version 2025.4.1 |
| 151 | +// @version 2025.4.1.1 |
152 | 152 | // @license MIT
|
153 | 153 | // @icon https://cdn.jsdelivr.net/gh/KudoAI/bravegpt@df624b0/assets/images/icons/bravegpt/icon48.png
|
154 | 154 | // @icon64 https://cdn.jsdelivr.net/gh/KudoAI/bravegpt@df624b0/assets/images/icons/bravegpt/icon64.png
|
|
405 | 405 | // Init DEBUG mode
|
406 | 406 | const config = {}
|
407 | 407 | const settings = {
|
408 |
| - isEnabled(key) { |
409 |
| - const reInvertFlags = /disabled|hidden/i |
410 |
| - return reInvertFlags.test(key) // flag in control key name |
411 |
| - && !reInvertFlags.test(this.controls[key]?.label || '') // but not in label msg key name |
412 |
| - ? !config[key] : config[key] // so invert since flag reps opposite state, else don't |
413 |
| - }, |
| 408 | + |
414 | 409 | load(...keys) {
|
415 | 410 | keys.flat().forEach(key => {
|
416 | 411 | config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
|
417 | 412 | this.controls?.[key]?.defaultVal ?? this.controls?.[key]?.type == 'toggle')
|
418 | 413 | })
|
419 | 414 | },
|
420 |
| - save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val } |
| 415 | + |
| 416 | + save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }, |
| 417 | + |
| 418 | + typeIsEnabled(key) { // for toggle.<auto|manual>Gen auto-toggles + notifs |
| 419 | + const reInvertSuffixes = /disabled|hidden/i |
| 420 | + return reInvertSuffixes.test(key) // flag in control key name |
| 421 | + && !reInvertSuffixes.test(this.controls[key]?.label || '') // but not in label msg key name |
| 422 | + ? !config[key] : config[key] // so invert since flag reps opposite type state, else don't |
| 423 | + } |
421 | 424 | }
|
422 | 425 | settings.load('debugMode')
|
423 | 426 |
|
|
3202 | 3205 | modeKey = `auto${log.toTitleCase(mode)}${ mode == 'get' ? 'Disabled' : '' }`
|
3203 | 3206 | let conflictingModeToggled = false // to extend this notif duration
|
3204 | 3207 | settings.save(modeKey, !config[modeKey])
|
3205 |
| - if (settings.isEnabled(modeKey)) { // this Auto-Gen mode toggled on, disable other one + Manual-Gen |
| 3208 | + if (settings.typeIsEnabled(modeKey)) { // this Auto-Gen mode toggled on, disable other one + Manual-Gen |
3206 | 3209 | const otherMode = validModes[+(mode == validModes[0])],
|
3207 | 3210 | otherModeKey = `auto${log.toTitleCase(otherMode)}${ otherMode == 'get' ? 'Disabled' : '' }`
|
3208 |
| - if (settings.isEnabled(otherModeKey)) { toggle.autoGen(otherMode) ; conflictingModeToggled = true } |
| 3211 | + if (settings.typeIsEnabled(otherModeKey)) { toggle.autoGen(otherMode) ; conflictingModeToggled = true } |
3209 | 3212 | ['prefix', 'suffix'].forEach(mode => {
|
3210 | 3213 | if (config[`${mode}Enabled`]) { toggle.manualGen(mode) ; conflictingModeToggled = true }})
|
3211 | 3214 | }
|
3212 |
| - notify(`${settings.controls[modeKey].label} ${toolbarMenu.state.words[+settings.isEnabled(modeKey)]}`, |
| 3215 | + notify(`${settings.controls[modeKey].label} ${toolbarMenu.state.words[+settings.typeIsEnabled(modeKey)]}`, |
3213 | 3216 | null, conflictingModeToggled ? 2.75 : null) // +1s duration if conflicting mode notif shown
|
3214 | 3217 | if (modals.settings.get()) { // update visual state of Settings toggle
|
3215 | 3218 | const modeToggle = document.querySelector(`[id*=${modeKey}] input`)
|
3216 |
| - if (modeToggle.checked != settings.isEnabled(modeKey)) modals.settings.toggle.switch(modeToggle) |
| 3219 | + if (modeToggle.checked != settings.typeIsEnabled(modeKey)) modals.settings.toggle.switch(modeToggle) |
3217 | 3220 | }
|
3218 | 3221 | },
|
3219 | 3222 |
|
|
3251 | 3254 | settings.save(modeKey, !config[modeKey])
|
3252 | 3255 | if (config[modeKey]) // Manual-Gen toggled on, disable all Auto-Gen
|
3253 | 3256 | ['get', 'summarize'].forEach(mode => {
|
3254 |
| - if (settings.isEnabled(`auto${log.toTitleCase(mode)}${ mode == 'get' ? 'Disabled' : '' }`)) { |
| 3257 | + if (settings.typeIsEnabled(`auto${log.toTitleCase(mode)}${ mode == 'get' ? 'Disabled' : '' }`)) { |
3255 | 3258 | toggle.autoGen(mode) ; autoGenToggled = true }
|
3256 | 3259 | })
|
3257 | 3260 | notify(`${settings.controls[modeKey].label} ${toolbarMenu.state.words[+config[modeKey]]}`,
|
|
0 commit comments