Skip to content

Commit

Permalink
Added settings.controls[key].defaultVal + reversed `settings.load()…
Browse files Browse the repository at this point in the history
…` to init `true` for toggles if val missing to eliminate dependency on reverse key naming
  • Loading branch information
adamlui committed Jan 12, 2025
1 parent 7ca7e4c commit 47662c3
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 130 deletions.
26 changes: 16 additions & 10 deletions amazongpt/greasemonkey/amazongpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @description Adds the magic of AI to Amazon shopping
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.11
// @version 2025.1.11.1
// @license MIT
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
Expand Down Expand Up @@ -229,9 +229,15 @@
// Init DEBUG mode
const config = {}
const settings = {
load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls?.[key]?.defaultVal || this.controls?.[key]?.type == 'toggle')
})
},
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
} ; settings.load('debugMode')
}
settings.load('debugMode')

// Define LOG props/functions
const log = {
Expand Down Expand Up @@ -346,23 +352,23 @@

// Init SETTINGS
log.debug('Initializing settings...')
Object.assign(settings, { controls: {
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses',
Object.assign(settings, { controls: { // displays top-to-bottom, left-to-right in Settings modal
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses', defaultVal: false,
label: app.msgs.menuLabel_proxyAPImode,
helptip: app.msgs.helptip_proxyAPImode },
streamingDisabled: { type: 'toggle', icon: 'signalStream',
streamingDisabled: { type: 'toggle', icon: 'signalStream', defaultVal: false,
label: app.msgs.mode_streaming,
helptip: app.msgs.helptip_streamingMode },
autoFocusChatbarDisabled: { type: 'toggle', mobile: false, icon: 'caretsInward',
label: app.msgs.menuLabel_autoFocusChatbar,
helptip: app.msgs.helptip_autoFocusChatbar },
autoScroll: { type: 'toggle', mobile: false, icon: 'arrowsDown',
autoScroll: { type: 'toggle', mobile: false, icon: 'arrowsDown', defaultVal: false,
label: `${app.msgs.mode_autoScroll} (${app.msgs.menuLabel_whenStreaming})`,
helptip: app.msgs.helptip_autoScroll },
bgAnimationsDisabled: { type: 'toggle', icon: 'sparkles',
bgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_background} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_bgAnimations },
fgAnimationsDisabled: { type: 'toggle', icon: 'sparkles',
fgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_foreground} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_fgAnimations },
replyLang: { type: 'prompt', icon: 'languageChars',
Expand All @@ -371,7 +377,7 @@
scheme: { type: 'modal', icon: 'scheme',
label: app.msgs.menuLabel_colorScheme,
helptip: app.msgs.helptip_colorScheme },
debugMode: { type: 'toggle', icon: 'bug',
debugMode: { type: 'toggle', icon: 'bug', defaultVal: false,
label: app.msgs.mode_debug,
helptip: app.msgs.helptip_debugMode },
about: { type: 'modal', icon: 'questionMarkCircle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
// @description:zu Ziba itshala lokucabanga okuzoshintshwa ngokuzenzakalelayo uma ukubuka chatgpt.com
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2025.1.10.1
// @version 2025.1.11
// @license MIT
// @icon https://assets.autoclearchatgpt.com/images/icons/openai/black/icon48.png?v=f461c06
// @icon64 https://assets.autoclearchatgpt.com/images/icons/openai/black/icon64.png?v=f461c06
Expand Down Expand Up @@ -376,17 +376,23 @@
const settings = {

controls: { // displays top-to-bottom in toolbar menu
autoclear: { type: 'toggle',
autoclear: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_autoclear, helptip: app.msgs.appDesc },
clearNow: { type: 'action', symbol: '🧹',
label: app.msgs.menuLabel_clearNow, helptip: app.msgs.helptip_clearNow },
toggleHidden: { type: 'toggle',
toggleHidden: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_toggleVis, helptip: app.msgs.helptip_toggleVis },
notifDisabled: { type: 'toggle',
notifDisabled: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_modeNotifs, helptip: app.msgs.helptip_modeNotifs }
},

load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
},

save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
}
settings.load(Object.keys(settings.controls))
Expand Down
42 changes: 24 additions & 18 deletions bravegpt/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 2025.1.10.1
// @version 2025.1.11
// @license MIT
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
Expand Down Expand Up @@ -385,9 +385,15 @@
// Init DEBUG mode
const config = {}
const settings = {
load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls?.[key]?.defaultVal || this.controls?.[key]?.type == 'toggle')
})
},
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
} ; settings.load('debugMode')
}
settings.load('debugMode')

// Define LOG props/functions
const log = {
Expand Down Expand Up @@ -502,44 +508,44 @@

// Init SETTINGS
log.debug('Initializing settings...')
Object.assign(settings, { controls: {
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses',
Object.assign(settings, { controls: { // displays top-to-bottom, left-to-right in Settings modal
proxyAPIenabled: { type: 'toggle', icon: 'sunglasses', defaultVal: false,
label: app.msgs.menuLabel_proxyAPImode,
helptip: app.msgs.helptip_proxyAPImode },
streamingDisabled: { type: 'toggle', icon: 'signalStream',
streamingDisabled: { type: 'toggle', icon: 'signalStream', defaultVal: false,
label: app.msgs.mode_streaming,
helptip: app.msgs.helptip_streamingMode },
autoGetDisabled: { type: 'toggle', icon: 'speechBalloonLasso',
autoGetDisabled: { type: 'toggle', icon: 'speechBalloonLasso', defaultVal: false,
label: app.msgs.menuLabel_autoGetAnswers,
helptip: app.msgs.helptip_autoGetAnswers },
autoFocusChatbarDisabled: { type: 'toggle', mobile: false, icon: 'caretsInward',
autoFocusChatbarDisabled: { type: 'toggle', mobile: false, icon: 'caretsInward', defaultVal: false,
label: app.msgs.menuLabel_autoFocusChatbar,
helptip: app.msgs.helptip_autoFocusChatbar },
autoScroll: { type: 'toggle', mobile: false, icon: 'arrowsDown',
autoScroll: { type: 'toggle', mobile: false, icon: 'arrowsDown', defaultVal: false,
label: `${app.msgs.mode_autoScroll} (${app.msgs.menuLabel_whenStreaming})`,
helptip: app.msgs.helptip_autoScroll },
rqDisabled: { type: 'toggle', icon: 'speechBalloons',
rqDisabled: { type: 'toggle', icon: 'speechBalloons', defaultVal: false,
label: `${app.msgs.menuLabel_show} ${app.msgs.menuLabel_relatedQueries}`,
helptip: app.msgs.helptip_showRelatedQueries },
prefixEnabled: { type: 'toggle', icon: 'slash',
prefixEnabled: { type: 'toggle', icon: 'slash', defaultVal: false,
label: `${app.msgs.menuLabel_require} "/" ${app.msgs.menuLabel_beforeQuery}`,
helptip: app.msgs.helptip_prefixMode },
suffixEnabled: { type: 'toggle', icon: 'questionMark',
suffixEnabled: { type: 'toggle', icon: 'questionMark', defaultVal: false,
label: `${app.msgs.menuLabel_require} "?" ${app.msgs.menuLabel_afterQuery}`,
helptip: app.msgs.helptip_suffixMode },
widerSidebar: { type: 'toggle', mobile: false, icon: 'widescreen',
widerSidebar: { type: 'toggle', mobile: false, icon: 'widescreen', defaultVal: false,
label: app.msgs.menuLabel_widerSidebar,
helptip: app.msgs.helptip_widerSidebar },
stickySidebar: { type: 'toggle', mobile: false, icon: 'webCorner',
stickySidebar: { type: 'toggle', mobile: false, icon: 'webCorner', defaultVal: false,
label: app.msgs.menuLabel_stickySidebar,
helptip: app.msgs.helptip_stickySidebar },
anchored: { type: 'toggle', mobile: false, icon: 'anchor',
anchored: { type: 'toggle', mobile: false, icon: 'anchor', defaultVal: false,
label: app.msgs.mode_anchor,
helptip: app.msgs.helptip_anchorMode },
bgAnimationsDisabled: { type: 'toggle', icon: 'sparkles',
bgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_background} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_bgAnimations },
fgAnimationsDisabled: { type: 'toggle', icon: 'sparkles',
fgAnimationsDisabled: { type: 'toggle', icon: 'sparkles', defaultVal: false,
label: `${app.msgs.menuLabel_foreground} ${app.msgs.menuLabel_animations}`,
helptip: app.msgs.helptip_fgAnimations },
replyLang: { type: 'prompt', icon: 'languageChars',
Expand All @@ -548,7 +554,7 @@
scheme: { type: 'modal', icon: 'scheme',
label: app.msgs.menuLabel_colorScheme,
helptip: app.msgs.helptip_colorScheme },
debugMode: { type: 'toggle', icon: 'bug',
debugMode: { type: 'toggle', icon: 'bug', defaultVal: false,
label: app.msgs.mode_debug,
helptip: app.msgs.helptip_debugMode },
about: { type: 'modal', icon: 'questionMarkCircle',
Expand Down
12 changes: 8 additions & 4 deletions chatgpt-auto-continue/chromium/extension/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.settings = {
},

controls: { // displays top-to-bottom in toolbar menu
get notifDisabled() { return { type: 'toggle',
get notifDisabled() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_modeNotifs'),
helptip: settings.getMsg('helptip_modeNotifs')
}}
Expand All @@ -19,13 +19,17 @@ window.settings = {
load(...keys) {
keys = keys.flat() // flatten array args nested by spread operator
if (typeof GM_info != 'undefined') // synchronously load from userscript manager storage
keys.forEach(key => window.config[key] = GM_getValue(
`${this.imports.app.configKeyPrefix}_${key}`, false))
keys.forEach(key => {
config[key] = GM_getValue(`${this.imports.app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
else // asynchronously load from browser extension storage
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => {
window.config[key] = result[key] || false ; resolve()
window.config[key] = key in result ? result[key] :
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle'
resolve()
}))))
},

Expand Down
12 changes: 8 additions & 4 deletions chatgpt-auto-continue/firefox/extension/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ window.settings = {
},

controls: { // displays top-to-bottom in toolbar menu
get notifDisabled() { return { type: 'toggle',
get notifDisabled() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_modeNotifs'),
helptip: settings.getMsg('helptip_modeNotifs')
}}
Expand All @@ -19,13 +19,17 @@ window.settings = {
load(...keys) {
keys = keys.flat() // flatten array args nested by spread operator
if (typeof GM_info != 'undefined') // synchronously load from userscript manager storage
keys.forEach(key => window.config[key] = GM_getValue(
`${this.imports.app.configKeyPrefix}_${key}`, false))
keys.forEach(key => {
config[key] = GM_getValue(`${this.imports.app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
else // asynchronously load from browser extension storage
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => {
window.config[key] = result[key] || false ; resolve()
window.config[key] = key in result ? result[key] :
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle'
resolve()
}))))
},

Expand Down
16 changes: 11 additions & 5 deletions chatgpt-auto-refresh/greasemonkey/chatgpt-auto-refresh.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
// @description:zu *NGOKUPHEPHA* susa ukusetha kabusha ingxoxo yemizuzu eyi-10 + amaphutha enethiwekhi ahlala njalo + Ukuhlolwa kwe-Cloudflare ku-ChatGPT.
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2025.1.10.1
// @version 2025.1.11
// @license MIT
// @icon https://assets.chatgptautorefresh.com/images/icons/openai/black/icon48.png?v=f11a0a8
// @icon64 https://assets.chatgptautorefresh.com/images/icons/openai/black/icon64.png?v=f11a0a8
Expand Down Expand Up @@ -390,17 +390,23 @@
const settings = {

controls: { // displays top-to-bottom in toolbar menu
arDisabled: { type: 'toggle',
arDisabled: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_autoRefresh },
toggleHidden: { type: 'toggle',
toggleHidden: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_toggleVis, helptip: app.msgs.helptip_toggleVis },
notifDisabled: { type: 'toggle',
notifDisabled: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_modeNotifs, helptip: app.msgs.helptip_modeNotifs },
refreshInterval: { type: 'prompt', symbol: '⌚',
label: app.msgs.menuLabel_refreshInt, helptip: app.msgs.helptip_refreshInt }
},

load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
},

save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
}
settings.load(Object.keys(settings.controls))
Expand Down
16 changes: 12 additions & 4 deletions chatgpt-auto-talk/greasemonkey/chatgpt-auto-talk.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
// @description:zu Dlala izimpendulo ze-ChatGPT ngokuzenzakalela
// @author Adam Lui
// @namespace https://github.com/adamlui
// @version 2025.1.10.1
// @version 2025.1.11
// @license MIT
// @icon https://assets.chatgptautotalk.com/images/icons/openai/black/icon48.png?v=9f1ed3c
// @icon64 https://assets.chatgptautotalk.com/images/icons/openai/black/icon64.png?v=9f1ed3c
Expand Down Expand Up @@ -373,11 +373,19 @@
const settings = {

controls: { // displays top-to-bottom in toolbar menu
autoTalkDisabled: { type: 'toggle', label: app.msgs.mode_autoTalk },
toggleHidden: { type: 'toggle', label: app.msgs.menuLabel_toggleVis, helptip: app.msgs.helptip_toggleVis }
autoTalkDisabled: { type: 'toggle', defaultVal: false,
label: app.msgs.mode_autoTalk },
toggleHidden: { type: 'toggle', defaultVal: false,
label: app.msgs.menuLabel_toggleVis, helptip: app.msgs.helptip_toggleVis }
},

load(...keys) {
keys.flat().forEach(key => {
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
},

load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
}
settings.load(Object.keys(settings.controls))
Expand Down
18 changes: 11 additions & 7 deletions chatgpt-infinity/chrome/extension/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ window.settings = {
},

controls: { // displays top-to-bottom in toolbar menu
get infinityMode() { return { type: 'toggle',
get infinityMode() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_infinityMode')
}},
get autoStart() { return { type: 'toggle',
get autoStart() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_autoStart'),
helptip: settings.getMsg('helptip_autoStart')
}},
get toggleHidden() { return { type: 'toggle',
get toggleHidden() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_toggleVis'),
helptip: settings.getMsg('helptip_toggleVis')
}},
get autoScrollDisabled() { return { type: 'toggle',
get autoScrollDisabled() { return { type: 'toggle', defaultVal: false,
label: settings.getMsg('menuLabel_autoScroll'),
helptip: settings.getMsg('helptip_autoScroll')
}},
Expand All @@ -45,13 +45,17 @@ window.settings = {
load(...keys) {
keys = keys.flat() // flatten array args nested by spread operator
if (typeof GM_info != 'undefined') // synchronously load from userscript manager storage
keys.forEach(key => window.config[key] = GM_getValue(
`${this.imports.app.configKeyPrefix}_${key}`, false))
keys.forEach(key => {
config[key] = GM_getValue(`${this.imports.app.configKeyPrefix}_${key}`,
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
})
else // asynchronously load from browser extension storage
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => {
window.config[key] = result[key] || false ; resolve()
window.config[key] = key in result ? result[key] :
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle'
resolve()
}))))
},

Expand Down
Loading

0 comments on commit 47662c3

Please sign in to comment.