|
235 | 235 | // @description:zu Thuthukisa iChatGPT ngemodi zesikrini ezibanzi/egcwele/ephezulu + imodi yokuvimbela i-spam. Futhi isebenza ku-perplexity.ai + poe.com!
|
236 | 236 | // @author Adam Lui
|
237 | 237 | // @namespace https://github.com/adamlui
|
238 |
| -// @version 2025.2.12.1 |
| 238 | +// @version 2025.2.12.2 |
239 | 239 | // @license MIT
|
240 | 240 | // @icon https://assets.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon48.png?v=844b16e
|
241 | 241 | // @icon64 https://assets.chatgptwidescreen.com/images/icons/widescreen-robot-emoji/icon64.png?v=844b16e
|
|
435 | 435 |
|
436 | 436 | // Define FUNCTIONS
|
437 | 437 |
|
438 |
| - const menu = { |
| 438 | + const toolbarMenu = { |
439 | 439 | ids: [], state: {
|
440 | 440 | symbols: ['❌', '✔️'], separator: env.scriptManager.name == 'Tampermonkey' ? ' — ' : ': ',
|
441 | 441 | words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()]
|
442 | 442 | },
|
443 | 443 |
|
444 | 444 | refresh() {
|
445 | 445 | if (typeof GM_unregisterMenuCommand == 'undefined') return
|
446 |
| - for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register() |
| 446 | + for (const id of this.ids) { GM_unregisterMenuCommand(id) } this.register() |
447 | 447 | },
|
448 | 448 |
|
449 | 449 | register() {
|
450 | 450 |
|
451 | 451 | // Show "Disabled (extension installed)"
|
452 | 452 | if (env.extensionInstalled) GM_registerMenuCommand(
|
453 |
| - `${menu.state.symbols[0]} ${app.msgs.menuLabel_disabled} (${app.msgs.menuLabel_extensionInstalled})`, |
| 453 | + `${this.state.symbols[0]} ${app.msgs.menuLabel_disabled} (${app.msgs.menuLabel_extensionInstalled})`, |
454 | 454 | () => modals.open('about'), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
|
455 | 455 | )
|
456 | 456 |
|
457 | 457 | // ...or add settings toggles
|
458 | 458 | else Object.keys(settings.controls).forEach(key => {
|
459 | 459 | if (sites[env.site].availFeatures.includes(key)) {
|
460 | 460 | const settingIsEnabled = config[key] ^ key.includes('Disabled')
|
461 |
| - const menuLabel = `${ settings.controls[key].symbol || menu.state.symbols[+settingIsEnabled] } ` |
| 461 | + const menuLabel = `${ settings.controls[key].symbol || this.state.symbols[+settingIsEnabled] } ` |
462 | 462 | + settings.controls[key].label
|
463 |
| - + menu.state.separator + menu.state.words[+settingIsEnabled] |
464 |
| - menu.ids.push(GM_registerMenuCommand(menuLabel, () => { |
| 463 | + + this.state.separator + this.state.words[+settingIsEnabled] |
| 464 | + this.ids.push(GM_registerMenuCommand(menuLabel, () => { |
465 | 465 | settings.save(key, !config[key]) ; sync.configToUI({ updatedKey: key })
|
466 | 466 | notify(`${settings.controls[key].label}: ${
|
467 |
| - menu.state.words[+(key.includes('Disabled') ^ config[key])]}`) |
| 467 | + this.state.words[+(key.includes('Disabled') ^ config[key])]}`) |
468 | 468 | }, env.scriptManager.supportsTooltips ? { title: settings.controls[key].helptip || ' ' } : undefined))
|
469 | 469 | }
|
470 | 470 | });
|
471 | 471 |
|
472 | 472 | // Add About/Donate entries
|
473 | 473 | ['about', 'donate'].forEach(entryType => {
|
474 | 474 | if (entryType === 'donate' && env.extensionInstalled) return
|
475 |
| - menu.ids.push(GM_registerMenuCommand( |
| 475 | + this.ids.push(GM_registerMenuCommand( |
476 | 476 | `${ entryType == 'about' ? '💡' : '💖' }`
|
477 | 477 | + ` ${app.msgs[`menuLabel_${entryType}`]} ${ entryType == 'about' ? app.msgs.appName : '' }`,
|
478 | 478 | () => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined
|
|
506 | 506 | if (config.notifDisabled && !msg.includes(app.msgs.menuLabel_modeNotifs)) return
|
507 | 507 |
|
508 | 508 | // Strip state word to append colored one later
|
509 |
| - const foundState = menu.state.words.find(word => msg.includes(word)) |
| 509 | + const foundState = toolbarMenu.state.words.find(word => msg.includes(word)) |
510 | 510 | if (foundState) msg = msg.replace(foundState, '')
|
511 | 511 |
|
512 | 512 | // Show notification
|
|
526 | 526 | }
|
527 | 527 | }
|
528 | 528 | const styledStateSpan = dom.create.elem('span')
|
529 |
| - styledStateSpan.style.cssText = stateStyles[foundState == menu.state.words[0] ? 'off' : 'on'][env.ui.scheme] |
| 529 | + styledStateSpan.style.cssText = stateStyles[ |
| 530 | + foundState == toolbarMenu.state.words[0] ? 'off' : 'on'][env.ui.scheme] |
530 | 531 | styledStateSpan.append(foundState) ; notif.append(styledStateSpan)
|
531 | 532 | }
|
532 | 533 | }
|
|
657 | 658 | update.style.tweaks() // sync TCB/NCB/HH/HF/BA
|
658 | 659 | update.style.chatbar() // sync WCB
|
659 | 660 | chatbar.tweak() // update ChatGPT chatbar inner width + left-align Perplexity Attach File button
|
660 |
| - menu.refresh() // to update state symbol/suffix |
| 661 | + toolbarMenu.refresh() // to update state symbol/suffix |
661 | 662 | if (options?.updatedKey == 'btnAnimationsDisabled' && !config.btnAnimationsDisabled) // apply/remove fx
|
662 | 663 | // ...to visually signal location + preview fx applied by Button Animations toggle-on
|
663 | 664 | buttons.animate()
|
|
678 | 679 | })()
|
679 | 680 | }), new Promise(resolve => setTimeout(() => resolve(false), 1500))])
|
680 | 681 |
|
681 |
| - menu.register() ; if (env.extensionInstalled) return |
| 682 | + toolbarMenu.register() ; if (env.extensionInstalled) return |
682 | 683 |
|
683 | 684 | // Init UI props
|
684 | 685 | if (env.site == 'chatgpt') {
|
|
0 commit comments