Skip to content

Commit b1a637f

Browse files
committed
Eliminated toolbarMenu.ids init to condense .register() ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/chatgpt-auto-refresh]
1 parent 9b91caa commit b1a637f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 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.3.31
223+
// @version 2025.4.1
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
@@ -423,7 +423,7 @@
423423
// Define MENU functions
424424

425425
const toolbarMenu = {
426-
ids: [], state: {
426+
state: {
427427
symbols: ['❌', '✔️'], separator: env.scriptManager.name == 'Tampermonkey' ? ' — ' : ': ',
428428
words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
429429
},
@@ -439,15 +439,15 @@
439439
settings.controls.refreshInterval.status = `${config.refreshInterval}s`
440440

441441
// Add toggles
442-
Object.keys(settings.controls).forEach(key => {
442+
this.ids = Object.keys(settings.controls).map(key => {
443443
const ctrlType = settings.controls[key].type
444444
const ctrlStatus = settings.controls[key].status
445445
const menuLabel = `${ settings.controls[key].symbol || this.state.symbols[+settings.isEnabled(key)] } `
446446
+ settings.controls[key].label
447447
+ ( ctrlType == 'toggle' ? this.state.separator
448448
+ this.state.words[+settings.isEnabled(key)]
449449
: ctrlStatus ? `— ${settings.controls[key].status}` : '' )
450-
this.ids.push(GM_registerMenuCommand(menuLabel, () => {
450+
return GM_registerMenuCommand(menuLabel, () => {
451451
if (ctrlType == 'toggle') {
452452
settings.save(key, !config[key])
453453
notify(`${settings.controls[key].label}: ${
@@ -472,13 +472,13 @@
472472
}}
473473
}
474474
syncConfigToUI({ updatedKey: key })
475-
}, env.scriptManager.supportsTooltips ? { title: settings.controls[key].helptip || ' ' } : undefined))
475+
}, env.scriptManager.supportsTooltips ? { title: settings.controls[key].helptip || ' ' } : undefined)
476476
});
477477

478478
// Add About/Donate entries
479479
['about', 'donate'].forEach(entryType => this.ids.push(GM_registerMenuCommand(
480-
`${ entryType == 'about' ? '💡' : '💖' }`
481-
+ ` ${app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
480+
`${ entryType == 'about' ? '💡' : '💖' } ${
481+
app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
482482
() => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
483483
)))
484484
}

0 commit comments

Comments
 (0)