Skip to content

Commit c33def3

Browse files
committed
Renamed settings.isEnabled to typeIsEnabled(), added/improved comments ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/chatgpt-auto-refresh]
1 parent 259d3a3 commit c33def3

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 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.4.1.2
223+
// @version 2025.4.1.3
224224
// @license MIT
225225
// @icon https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-refresh@f11a0a8/assets/images/icons/openai/black/icon48.png
226226
// @icon64 https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-refresh@f11a0a8/assets/images/icons/openai/black/icon64.png
@@ -401,21 +401,21 @@
401401
label: app.msgs.menuLabel_refreshInt, helptip: app.msgs.helptip_refreshInt }
402402
},
403403

404-
isEnabled(key) {
405-
const reInvertFlags = /disabled|hidden/i
406-
return reInvertFlags.test(key) // flag in control key name
407-
&& !reInvertFlags.test(this.controls[key]?.label || '') // but not in label msg key name
408-
? !config[key] : config[key] // so invert since flag reps opposite state, else don't
409-
},
410-
411404
load(...keys) {
412405
keys.flat().forEach(key => {
413406
config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
414407
this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle')
415408
})
416409
},
417410

418-
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }
411+
save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val },
412+
413+
typeIsEnabled(key) { // for menu labels + notifs to return ON/OFF for type w/o suffix
414+
const reInvertSuffixes = /disabled|hidden/i
415+
return reInvertSuffixes.test(key) // flag in control key name
416+
&& !reInvertSuffixes.test(this.controls[key]?.label || '') // but not in label msg key name
417+
? !config[key] : config[key] // so invert since flag reps opposite type state, else don't
418+
}
419419
}
420420
settings.load(Object.keys(settings.controls))
421421
if (!config.refreshInterval) settings.save('refreshInterval', 30) // init refresh interval to 30 secs if unset
@@ -442,15 +442,15 @@
442442
this.ids = Object.keys(settings.controls).map(key => {
443443
const ctrlType = settings.controls[key].type
444444
const ctrlStatus = settings.controls[key].status
445-
const menuLabel = `${ settings.controls[key].symbol || this.state.symbols[+settings.isEnabled(key)] } `
446-
+ settings.controls[key].label
447-
+ ( ctrlType == 'toggle' ? this.state.separator
448-
+ this.state.words[+settings.isEnabled(key)]
449-
: ctrlStatus ? `— ${settings.controls[key].status}` : '' )
445+
const menuLabel = `${
446+
settings.controls[key].symbol || this.state.symbols[+settings.typeIsEnabled(key)] } ${
447+
settings.controls[key].label} ${
448+
ctrlType == 'toggle' ? this.state.separator + this.state.words[+settings.typeIsEnabled(key)]
449+
: ctrlStatus ? `— ${ctrlStatus}` : '' }`
450450
return GM_registerMenuCommand(menuLabel, () => {
451451
if (ctrlType == 'toggle') {
452452
settings.save(key, !config[key])
453-
notify(`${settings.controls[key].label}: ${this.state.words[+settings.isEnabled(key)]}`)
453+
notify(`${settings.controls[key].label}: ${this.state.words[+settings.typeIsEnabled(key)]}`)
454454
} else { // Refresh Interval prompt
455455
while (true) {
456456
const refreshInterval = prompt(

0 commit comments

Comments
 (0)