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 ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/autoclear-chatgpt-history]
  • Loading branch information
kudo-sync-bot committed Jan 12, 2025
1 parent 9b0a421 commit 9df83fe
Showing 1 changed file with 11 additions and 5 deletions.
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

0 comments on commit 9df83fe

Please sign in to comment.