|
220 | 220 | // @description:zu *NGOKUPHEPHA* susa ukusetha kabusha ingxoxo yemizuzu eyi-10 + amaphutha enethiwekhi ahlala njalo + Ukuhlolwa kwe-Cloudflare ku-ChatGPT.
|
221 | 221 | // @author Adam Lui
|
222 | 222 | // @namespace https://github.com/adamlui
|
223 |
| -// @version 2025.4.1.2 |
| 223 | +// @version 2025.4.1.3 |
224 | 224 | // @license MIT
|
225 | 225 | // @icon https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-refresh@f11a0a8/assets/images/icons/openai/black/icon48.png
|
226 | 226 | // @icon64 https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-refresh@f11a0a8/assets/images/icons/openai/black/icon64.png
|
|
401 | 401 | label: app.msgs.menuLabel_refreshInt, helptip: app.msgs.helptip_refreshInt }
|
402 | 402 | },
|
403 | 403 |
|
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 |
| - |
411 | 404 | load(...keys) {
|
412 | 405 | keys.flat().forEach(key => {
|
413 | 406 | config[key] = GM_getValue(`${app.configKeyPrefix}_${key}`,
|
414 | 407 | this.controls[key]?.defaultVal ?? this.controls[key]?.type == 'toggle')
|
415 | 408 | })
|
416 | 409 | },
|
417 | 410 |
|
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 | + } |
419 | 419 | }
|
420 | 420 | settings.load(Object.keys(settings.controls))
|
421 | 421 | if (!config.refreshInterval) settings.save('refreshInterval', 30) // init refresh interval to 30 secs if unset
|
|
442 | 442 | this.ids = Object.keys(settings.controls).map(key => {
|
443 | 443 | const ctrlType = settings.controls[key].type
|
444 | 444 | 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}` : '' }` |
450 | 450 | return GM_registerMenuCommand(menuLabel, () => {
|
451 | 451 | if (ctrlType == 'toggle') {
|
452 | 452 | 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)]}`) |
454 | 454 | } else { // Refresh Interval prompt
|
455 | 455 | while (true) {
|
456 | 456 | const refreshInterval = prompt(
|
|
0 commit comments