Skip to content

Commit 2b1cfa0

Browse files
committed
Added settings.controls[key].defaultVal + reversed settings.load() 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/chatgpt-auto-refresh]
1 parent 2332520 commit 2b1cfa0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

chatgpt/chatgpt-auto-refresh/chatgpt-auto-refresh.user.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
// @description:zu *NGOKUPHEPHA* susa ukusetha kabusha ingxoxo yemizuzu eyi-10 + amaphutha enethiwekhi ahlala njalo + Ukuhlolwa kwe-Cloudflare ku-ChatGPT.
221221
// @author Adam Lui
222222
// @namespace https://github.com/adamlui
223-
// @version 2025.1.10.1
223+
// @version 2025.1.11
224224
// @license MIT
225225
// @icon https://assets.chatgptautorefresh.com/images/icons/openai/black/icon48.png?v=f11a0a8
226226
// @icon64 https://assets.chatgptautorefresh.com/images/icons/openai/black/icon64.png?v=f11a0a8
@@ -390,17 +390,23 @@
390390
const settings = {
391391

392392
controls: { // displays top-to-bottom in toolbar menu
393-
arDisabled: { type: 'toggle',
393+
arDisabled: { type: 'toggle', defaultVal: false,
394394
label: app.msgs.menuLabel_autoRefresh },
395-
toggleHidden: { type: 'toggle',
395+
toggleHidden: { type: 'toggle', defaultVal: false,
396396
label: app.msgs.menuLabel_toggleVis, helptip: app.msgs.helptip_toggleVis },
397-
notifDisabled: { type: 'toggle',
397+
notifDisabled: { type: 'toggle', defaultVal: false,
398398
label: app.msgs.menuLabel_modeNotifs, helptip: app.msgs.helptip_modeNotifs },
399399
refreshInterval: { type: 'prompt', symbol: '⌚',
400400
label: app.msgs.menuLabel_refreshInt, helptip: app.msgs.helptip_refreshInt }
401401
},
402402

403-
load(...keys) { keys.flat().forEach(key => config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`, false)) },
403+
load(...keys) {
404+
keys.flat().forEach(key => {
405+
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
406+
this.controls[key]?.defaultVal || this.controls[key]?.type == 'toggle')
407+
})
408+
},
409+
404410
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
405411
}
406412
settings.load(Object.keys(settings.controls))

0 commit comments

Comments
 (0)