|
308 | 308 | // Init SETTINGS |
309 | 309 | settings.load(Object.keys(settings.controls).filter(key => key != 'infinityMode')) // exclude infinityMode... |
310 | 310 | settings.save('infinityMode', false) // ...to always init as false |
311 | | - if (!config.replyLanguage) settings.save('replyLanguage', env.browser.language) // init reply language if unset |
312 | | - if (!config.replyTopic) settings.save('replyTopic', app.msgs.menuLabel_all) // init reply topic if unset |
313 | | - if (!config.replyInterval) settings.save('replyInterval', 7) // init refresh interval to 7 secs if unset |
| 311 | + if (!app.config.replyLanguage) settings.save('replyLanguage', env.browser.language) // init reply language if unset |
| 312 | + if (!app.config.replyTopic) settings.save('replyTopic', app.msgs.menuLabel_all) // init reply topic if unset |
| 313 | + if (!app.config.replyInterval) settings.save('replyInterval', 7) // init refresh interval to 7 secs if unset |
314 | 314 |
|
315 | 315 | // Define MENU functions |
316 | 316 |
|
|
343 | 343 | entryData.symbol || this.state.symbols[+settings.typeIsEnabled(key)] } ${entryData.label} ${ |
344 | 344 | entryData.type == 'toggle' ? this.state.separator |
345 | 345 | + this.state.words[+settings.typeIsEnabled(key)] |
346 | | - : entryData.type == 'slider' ? ': ' + config[key] + entryData.labelSuffix || '' |
| 346 | + : entryData.type == 'slider' ? ': ' + app.config[key] + entryData.labelSuffix || '' |
347 | 347 | : entryData.status ? ` — ${entryData.status}` : '' }` |
348 | 348 | return GM_registerMenuCommand(menuLabel, () => { |
349 | 349 | if (entryData.type == 'toggle') { |
350 | 350 | settings.save(key, !config[key]) |
351 | 351 | feedback.notify(`${entryData.label}: ${this.state.words[+settings.typeIsEnabled(key)]}`) |
352 | 352 | } else if (key == 'replyLanguage') { |
353 | | - let replyLang = prompt(`${app.msgs.prompt_updateReplyLang}:`, config.replyLanguage) |
| 353 | + let replyLang = prompt(`${app.msgs.prompt_updateReplyLang}:`, app.config.replyLanguage) |
354 | 354 | if (replyLang == null) return // user cancelled so do nothing |
355 | 355 | else if (!/\d/.test(replyLang)) { // valid reply language set |
356 | 356 | replyLang = ( // auto-case for menu/alert aesthetics |
|
364 | 364 | } |
365 | 365 | } else if (key == 'replyTopic') { |
366 | 366 | let replyTopic = prompt(( app.msgs.prompt_updateReplyTopic ) |
367 | | - + ' (' + ( app.msgs.prompt_orEnter ) + ' \'ALL\'):', config.replyTopic) |
| 367 | + + ' (' + ( app.msgs.prompt_orEnter ) + ' \'ALL\'):', app.config.replyTopic) |
368 | 368 | if (replyTopic != null) { // user didn't cancel |
369 | 369 | replyTopic = string.toTitleCase(replyTopic.toString()) // for menu/alert aesthetics |
370 | 370 | settings.save('replyTopic', |
|
376 | 376 | ) |
377 | 377 | } |
378 | 378 | } else if (key == 'replyInterval') { |
379 | | - const replyInterval = prompt(`${app.msgs.prompt_updateReplyInt}:`, config.replyInterval) |
| 379 | + const replyInterval = prompt(`${app.msgs.prompt_updateReplyInt}:`, app.config.replyInterval) |
380 | 380 | if (replyInterval == null) return // user cancelled so do nothing |
381 | 381 | else if (!isNaN(parseInt(replyInterval, 10)) && parseInt(replyInterval, 10) > 4) { |
382 | 382 | settings.save('replyInterval', parseInt(replyInterval, 10)) |
|
487 | 487 | // Add LISTENER to auto-disable Infinity Mode |
488 | 488 | if ('hidden' in document) // ...if Page Visibility API supported |
489 | 489 | document.onvisibilitychange = () => { |
490 | | - if (config.infinityMode) { |
| 490 | + if (app.config.infinityMode) { |
491 | 491 | settings.save('infinityMode', false) ; sync.configToUI({ updatedKey: 'infinityMode' }) } |
492 | 492 | } |
493 | 493 |
|
|
497 | 497 | toggles.sidebar.insert() |
498 | 498 |
|
499 | 499 | // Auto-start if enabled |
500 | | - if (config.autoStart) { |
| 500 | + if (app.config.autoStart) { |
501 | 501 | settings.save('infinityMode', true) ; sync.configToUI({ updatedKey: 'infinityMode' }) |
502 | 502 | feedback.notify(`${app.msgs.menuLabel_autoStart}: ${app.msgs.state_on.toUpperCase()}`) |
503 | 503 | } |
504 | 504 |
|
505 | 505 | // Monitor NODE CHANGES to maintain sidebar toggle visibility |
506 | 506 | new MutationObserver(() => { |
507 | | - if (!config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar) |
| 507 | + if (!app.config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar) |
508 | 508 | && !document.querySelector(`.${toggles.sidebar.class}`) |
509 | 509 | && toggles.sidebar.status != 'inserting' |
510 | 510 | ) { toggles.sidebar.status = 'missing' ; toggles.sidebar.insert() } |
|
0 commit comments