Skip to content

Commit c64c89c

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

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

chatgpt/chatgpt-auto-continue/chatgpt-auto-continue.user.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
// @description:zu ⚡ Terus menghasilkan imibuzo eminingi ye-ChatGPT ngokwesizulu
220220
// @author Adam Lui
221221
// @namespace https://github.com/adamlui
222-
// @version 2025.3.31
222+
// @version 2025.4.1
223223
// @license MIT
224224
// @icon https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-continue@a8c9387/assets/images/icons/continue-symbol/black/icon48.png
225225
// @icon64 https://cdn.jsdelivr.net/gh/adamlui/chatgpt-auto-continue@a8c9387/assets/images/icons/continue-symbol/black/icon64.png
@@ -369,7 +369,7 @@
369369
// Define MENU functions
370370

371371
const toolbarMenu = {
372-
ids: [], state: {
372+
state: {
373373
symbols: ['❌', '✔️'], separator: env.scriptManager.name == 'Tampermonkey' ? ' — ' : ': ',
374374
words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
375375
},
@@ -382,29 +382,30 @@
382382
register() {
383383

384384
// Show "Disabled (extension active)"
385-
if (env.extensionActive)
385+
this.ids = env.extensionActive ? [
386386
GM_registerMenuCommand(`${this.state.symbols[0]} ${
387387
toTitleCase(app.msgs.state_disabled)} (${app.msgs.menuLabel_extensionActive})`,
388388
() => modals.open('about'), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined )
389+
]
389390

390391
// ...or add settings toggles
391-
else Object.keys(settings.controls).forEach(key => {
392+
: Object.keys(settings.controls).map(key => {
392393
const menuLabel = `${ settings.controls[key].symbol || this.state.symbols[+settings.isEnabled(key)] } `
393394
+ settings.controls[key].label
394395
+ this.state.separator + this.state.words[+settings.isEnabled(key)]
395-
this.ids.push(GM_registerMenuCommand(menuLabel, () => {
396+
return GM_registerMenuCommand(menuLabel, () => {
396397
settings.save(key, !config[key]) ; syncConfigToUI({ updatedKey: key })
397398
notify(`${settings.controls[key].label}: ${
398399
this.state.words[+(/disabled/i.test(key) ^ config[key])]}`)
399-
}, env.scriptManager.supportsTooltips ? { title: settings.controls[key].helptip || ' ' } : undefined))
400+
}, env.scriptManager.supportsTooltips ? { title: settings.controls[key].helptip || ' ' } : undefined)
400401
});
401402

402403
// Add About/Donate entries
403404
['about', 'donate'].forEach(entryType => {
404405
if (entryType === 'donate' && env.extensionActive) return
405406
this.ids.push(GM_registerMenuCommand(
406-
`${ entryType == 'about' ? '💡' : '💖' }`
407-
+ ` ${app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
407+
`${ entryType == 'about' ? '💡' : '💖' } ${
408+
app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
408409
() => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
409410
))
410411
})

0 commit comments

Comments
 (0)