|
148 | 148 | // @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!) |
149 | 149 | // @author KudoAI |
150 | 150 | // @namespace https://kudoai.com |
151 | | -// @version 2025.2.12.3 |
| 151 | +// @version 2025.2.12.4 |
152 | 152 | // @license MIT |
153 | 153 | // @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0 |
154 | 154 | // @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0 |
|
587 | 587 |
|
588 | 588 | // Define MENU functions |
589 | 589 |
|
590 | | - const menu = { |
| 590 | + const toolbarMenu = { |
591 | 591 | ids: [], state: { |
592 | 592 | symbols: ['❌', '✔️'], separator: env.scriptManager.name == 'Tampermonkey' ? ' — ' : ': ', |
593 | 593 | words: [app.msgs.state_off.toUpperCase(), app.msgs.state_on.toUpperCase()] |
|
596 | 596 | refresh() { |
597 | 597 | if (typeof GM_unregisterMenuCommand == 'undefined') { |
598 | 598 | log.debug('GM_unregisterMenuCommand not supported.') ; return } |
599 | | - for (const id of menu.ids) { GM_unregisterMenuCommand(id) } menu.register() |
| 599 | + for (const id of this.ids) { GM_unregisterMenuCommand(id) } this.register() |
600 | 600 | }, |
601 | 601 |
|
602 | 602 | register() { |
603 | 603 |
|
604 | 604 | // Add Proxy API Mode toggle |
605 | | - const pmLabel = menu.state.symbols[+config.proxyAPIenabled] + ' ' |
| 605 | + const pmLabel = this.state.symbols[+config.proxyAPIenabled] + ' ' |
606 | 606 | + settings.controls.proxyAPIenabled.label + ' ' |
607 | | - + menu.state.separator + menu.state.words[+config.proxyAPIenabled] |
608 | | - menu.ids.push(GM_registerMenuCommand(pmLabel, toggle.proxyMode, |
| 607 | + + this.state.separator + this.state.words[+config.proxyAPIenabled] |
| 608 | + this.ids.push(GM_registerMenuCommand(pmLabel, toggle.proxyMode, |
609 | 609 | env.scriptManager.supportsTooltips ? { title: settings.controls.proxyAPIenabled.helptip } : undefined)); |
610 | 610 |
|
611 | 611 | // Add About/Settings entries |
612 | | - ['about', 'settings'].forEach(entryType => menu.ids.push(GM_registerMenuCommand( |
| 612 | + ['about', 'settings'].forEach(entryType => this.ids.push(GM_registerMenuCommand( |
613 | 613 | entryType == 'about' ? `💡 ${settings.controls.about.label}` : `⚙️ ${app.msgs.menuLabel_settings}`, |
614 | 614 | () => modals.open(entryType), env.scriptManager.supportsTooltips ? { title: ' ' } : undefined |
615 | 615 | ))) |
|
689 | 689 | function notify(msg, pos = '', notifDuration = '', shadow = 'shadow') { |
690 | 690 |
|
691 | 691 | // Strip state word to append styled one later |
692 | | - const foundState = menu.state.words.find(word => msg.includes(word)) |
| 692 | + const foundState = toolbarMenu.state.words.find(word => msg.includes(word)) |
693 | 693 | if (foundState) msg = msg.replace(foundState, '') |
694 | 694 |
|
695 | 695 | // Show notification |
|
726 | 726 | } |
727 | 727 | const styledStateSpan = dom.create.elem('span') |
728 | 728 | styledStateSpan.style.cssText = `font-weight: bold ; ${ |
729 | | - stateStyles[foundState == menu.state.words[0] ? 'off' : 'on'][env.ui.site.scheme] }` |
| 729 | + stateStyles[foundState == toolbarMenu.state.words[0] ? 'off' : 'on'][env.ui.site.scheme] }` |
730 | 730 | styledStateSpan.append(foundState) ; notif.insertBefore(styledStateSpan, notif.children[2]) |
731 | 731 | } |
732 | 732 | } |
|
1199 | 1199 | key.includes('Disabled') ^ config[key] ? 'OFF' : 'ON' }...`) |
1200 | 1200 | settings.save(key, !config[key]) // update config |
1201 | 1201 | notify(`${settings.controls[key].label} ${ |
1202 | | - menu.state.words[+(key.includes('Disabled') ^ config[key])]}`) |
| 1202 | + toolbarMenu.state.words[+(key.includes('Disabled') ^ config[key])]}`) |
1203 | 1203 | log[key.includes('debug') ? 'info' : 'debug'](`Success! config.${key} = ${config[key]}`) |
1204 | 1204 | } |
1205 | 1205 | } |
|
2866 | 2866 | if (anchorToggle.checked != config.anchored) modals.settings.toggle.switch(anchorToggle) |
2867 | 2867 | } |
2868 | 2868 | menus.pin.topPos = menus.pin.rightPos = null |
2869 | | - notify(`${app.msgs.mode_anchor} ${menu.state.words[+config.anchored]}`) |
| 2869 | + notify(`${app.msgs.mode_anchor} ${toolbarMenu.state.words[+config.anchored]}`) |
2870 | 2870 | }, |
2871 | 2871 |
|
2872 | 2872 | animations(layer) { |
|
2884 | 2884 | // Toggle button glow |
2885 | 2885 | if (env.ui.app.scheme == 'dark') toggle.btnGlow() |
2886 | 2886 | } |
2887 | | - notify(`${settings.controls[configKey].label} ${menu.state.words[+!config[configKey]]}`) |
| 2887 | + notify(`${settings.controls[configKey].label} ${toolbarMenu.state.words[+!config[configKey]]}`) |
2888 | 2888 | }, |
2889 | 2889 |
|
2890 | 2890 | autoGet() { |
2891 | 2891 | settings.save('autoGetDisabled', !config.autoGetDisabled) |
2892 | 2892 | if (appDiv.querySelector('[class*=standby-btn]')) show.reply.standbyBtnClickHandler() |
2893 | 2893 | if (!config.autoGetDisabled) // disable Prefix/Suffix mode if enabled |
2894 | 2894 | ['prefix', 'suffix'].forEach(mode => config[`${mode}Enabled`] && toggle.manualGet(mode)) |
2895 | | - notify(`${settings.controls.autoGetDisabled.label} ${menu.state.words[+!config.autoGetDisabled]}`) |
| 2895 | + notify(`${settings.controls.autoGetDisabled.label} ${toolbarMenu.state.words[+!config.autoGetDisabled]}`) |
2896 | 2896 | if (modals.settings.get()) { // update visual state of Settings toggle |
2897 | 2897 | const autoGetToggle = document.querySelector('[id*=autoGet] input') |
2898 | 2898 | if (autoGetToggle.checked == config.autoGetDisabled) modals.settings.toggle.switch(autoGetToggle) |
|
2931 | 2931 | const modeKey = `${mode}Enabled` |
2932 | 2932 | settings.save(modeKey, !config[modeKey]) |
2933 | 2933 | if (config[modeKey] && !config.autoGetDisabled) toggle.autoGet() // disable Auto-Get mode if enabled |
2934 | | - notify(`${settings.controls[modeKey].label} ${menu.state.words[+config[modeKey]]}`) |
| 2934 | + notify(`${settings.controls[modeKey].label} ${toolbarMenu.state.words[+config[modeKey]]}`) |
2935 | 2935 | if (modals.settings.get()) { // update visual state of Settings toggle |
2936 | 2936 | const modeToggle = document.querySelector(`[id*=${modeKey}] input`) |
2937 | 2937 | if (modeToggle.checked != config[modeKey]) modals.settings.toggle.switch(modeToggle) |
|
2957 | 2957 |
|
2958 | 2958 | proxyMode() { |
2959 | 2959 | settings.save('proxyAPIenabled', !config.proxyAPIenabled) |
2960 | | - notify(`${app.msgs.menuLabel_proxyAPImode} ${menu.state.words[+config.proxyAPIenabled]}`) |
2961 | | - menu.refresh() |
| 2960 | + notify(`${app.msgs.menuLabel_proxyAPImode} ${toolbarMenu.state.words[+config.proxyAPIenabled]}`) |
| 2961 | + toolbarMenu.refresh() |
2962 | 2962 | if (modals.settings.get()) { // update visual states of Settings toggles |
2963 | 2963 | const proxyToggle = document.querySelector('[id*=proxy] input'), |
2964 | 2964 | streamingToggle = document.querySelector('[id*=streaming] input') |
|
2980 | 2980 | .then(queries => show.related(queries)) |
2981 | 2981 | .catch(err => { log.error(err.message) ; api.tryNew(get.related) }) |
2982 | 2982 | update.answerPreMaxHeight() |
2983 | | - notify(`${app.msgs.menuLabel_relatedQueries} ${menu.state.words[+!config.rqDisabled]}`) |
| 2983 | + notify(`${app.msgs.menuLabel_relatedQueries} ${toolbarMenu.state.words[+!config.rqDisabled]}`) |
2984 | 2984 | }, |
2985 | 2985 |
|
2986 | 2986 | sidebar(mode, state = '') { |
|
3007 | 3007 | if (mode == 'sticky' && prevStickyState == config.stickySidebar) return |
3008 | 3008 | notify(`${ app.msgs[`menuLabel_${ mode }Sidebar`] |
3009 | 3009 | || mode.charAt(0).toUpperCase() + mode.slice(1) + ' Sidebar' } ${ |
3010 | | - menu.state.words[+config[configKeyName]]}`) |
| 3010 | + toolbarMenu.state.words[+config[configKeyName]]}`) |
3011 | 3011 | }, |
3012 | 3012 |
|
3013 | 3013 | streaming() { |
|
3038 | 3038 | alert.querySelector('.modal-close-btn').click() ; toggle.proxyMode() } |
3039 | 3039 | } else { // functional toggle |
3040 | 3040 | settings.save('streamingDisabled', !config.streamingDisabled) |
3041 | | - notify(`${settings.controls.streamingDisabled.label} ${menu.state.words[+!config.streamingDisabled]}`) |
| 3041 | + notify(`${settings.controls.streamingDisabled.label} ${ |
| 3042 | + toolbarMenu.state.words[+!config.streamingDisabled]}`) |
3042 | 3043 | } |
3043 | 3044 | }, |
3044 | 3045 |
|
|
4002 | 4003 |
|
4003 | 4004 | // Run MAIN routine |
4004 | 4005 |
|
4005 | | - menu.register() |
| 4006 | + toolbarMenu.register() |
4006 | 4007 |
|
4007 | 4008 | // Init UI props |
4008 | 4009 | env.ui = { app: { scheme: config.scheme || getScheme() }, site: { scheme: getScheme() }} |
|
0 commit comments