|
334 | 334 |
|
335 | 335 | load(...keys) { |
336 | 336 | keys.flat().forEach(key => |
337 | | - config[key] = processKey(key, GM_getValue(`${app.configKeyPrefix}_${key}`, undefined))) |
| 337 | + app.config[key] = processKey(key, GM_getValue(`${app.configKeyPrefix}_${key}`, undefined))) |
338 | 338 | function processKey(key, val) { |
339 | 339 | const ctrl = settings.controls?.[key] |
340 | 340 | if (val != undefined && ( // validate stored val |
|
345 | 345 | } |
346 | 346 | }, |
347 | 347 |
|
348 | | - save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; config[key] = val }, |
| 348 | + save(key, val) { GM_setValue(`${app.configKeyPrefix}_${key}`, val) ; app.config[key] = val }, |
349 | 349 |
|
350 | 350 | typeIsEnabled(key) { // for menu labels + notifs to return ON/OFF |
351 | 351 | const reInvertSuffixes = /disabled|hidden/i |
352 | 352 | return reInvertSuffixes.test(key) // flag in control key name |
353 | 353 | && !reInvertSuffixes.test(this.controls[key]?.label || '') // but not in label msg key name |
354 | | - ? !config[key] : config[key] // so invert since flag reps opposite type state, else don't |
| 354 | + ? !config[key] : app.config[key] // so invert since flag reps opposite type state, else don't |
355 | 355 | } |
356 | 356 | } |
357 | 357 | settings.load(Object.keys(settings.controls)) |
|
379 | 379 | entryData.symbol || this.state.symbols[+settings.typeIsEnabled(key)] } ${entryData.label} ${ |
380 | 380 | entryData.type == 'toggle' ? this.state.separator |
381 | 381 | + this.state.words[+settings.typeIsEnabled(key)] |
382 | | - : entryData.type == 'slider' ? ': ' + config[key] + entryData.labelSuffix || '' |
| 382 | + : entryData.type == 'slider' ? ': ' + app.config[key] + entryData.labelSuffix || '' |
383 | 383 | : entryData.status ? ` — ${entryData.status}` : '' }` |
384 | 384 | return GM_registerMenuCommand(menuLabel, () => { |
385 | 385 | if (entryData.type == 'toggle') { |
|
422 | 422 | // Define FEEDBACK functions |
423 | 423 |
|
424 | 424 | function notify(msg, pos = '', notifDuration = '', shadow = '') { |
425 | | - if (config.notifDisabled && !msg.includes(app.msgs.menuLabel_modeNotifs)) return |
| 425 | + if (app.config.notifDisabled && !msg.includes(app.msgs.menuLabel_modeNotifs)) return |
426 | 426 |
|
427 | 427 | // Strip state word to append colored one later |
428 | 428 | const foundState = toolbarMenu.state.words.find(word => msg.includes(word)) |
|
675 | 675 | } |
676 | 676 |
|
677 | 677 | function syncConfigToUI({ updatedKey } = {}) { |
678 | | - if (updatedKey == 'autoclear' && config.autoclear) clearChatsAndGoHome() |
| 678 | + if (updatedKey == 'autoclear' && app.config.autoclear) clearChatsAndGoHome() |
679 | 679 | if (/autoclear|toggleHidden/.test(updatedKey)) toggles.sidebar.update.state() |
680 | 680 | toolbarMenu.refresh() // prefixes/suffixes |
681 | 681 | } |
|
709 | 709 | this.div.style.setProperty('--item-background-color', |
710 | 710 | `var(--sidebar-surface-${ type == 'mouseover' ? 'secondary' : 'primary' })`) |
711 | 711 | this.div.onclick = () => { |
712 | | - settings.save('autoclear', !config.autoclear) ; syncConfigToUI({ updatedKey: 'autoclear' }) |
| 712 | + settings.save('autoclear', !app.config.autoclear) ; syncConfigToUI({ updatedKey: 'autoclear' }) |
713 | 713 | notify(`${app.msgs.mode_autoclear}: ${toolbarMenu.state.words[+config.autoclear]}`) |
714 | 714 | } |
715 | 715 | }, |
|
819 | 819 |
|
820 | 820 | state() { |
821 | 821 | if (!toggles.sidebar.div) return // since toggle never created = sidebar missing |
822 | | - toggles.sidebar.div.style.display = config.toggleHidden ? 'none' : 'flex' |
823 | | - const isOn = config.autoclear |
| 822 | + toggles.sidebar.div.style.display = app.config.toggleHidden ? 'none' : 'flex' |
| 823 | + const isOn = app.config.autoclear |
824 | 824 | toggles.sidebar.toggleLabel.textContent = `${app.msgs.mode_autoclear} ` |
825 | 825 | + app.msgs[`state_${ isOn ? 'enabled' : 'disabled' }`] |
826 | 826 | requestAnimationFrame(() => { |
|
842 | 842 | toggles.sidebar.insert() |
843 | 843 |
|
844 | 844 | // AUTO-CLEAR on first visit if enabled |
845 | | - if (config.autoclear) clearChatsAndGoHome() |
| 845 | + if (app.config.autoclear) clearChatsAndGoHome() |
846 | 846 |
|
847 | 847 | // Monitor NODE CHANGES to maintain sidebar toggle visibility |
848 | 848 | new MutationObserver(() => { |
849 | | - if (!config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar) |
| 849 | + if (!app.config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar) |
850 | 850 | && !document.querySelector(`.${toggles.sidebar.class}`) |
851 | 851 | && toggles.sidebar.status != 'inserting' |
852 | 852 | ) { toggles.sidebar.status = 'missing' ; toggles.sidebar.insert() } |
|
0 commit comments