Skip to content

Commit d74ea83

Browse files
committed
1 parent 2e9ba23 commit d74ea83

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

chatgpt/autoclear-chatgpt-history/autoclear-chatgpt-history.user.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@
334334

335335
load(...keys) {
336336
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)))
338338
function processKey(key, val) {
339339
const ctrl = settings.controls?.[key]
340340
if (val != undefined && ( // validate stored val
@@ -345,13 +345,13 @@
345345
}
346346
},
347347

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 },
349349

350350
typeIsEnabled(key) { // for menu labels + notifs to return ON/OFF
351351
const reInvertSuffixes = /disabled|hidden/i
352352
return reInvertSuffixes.test(key) // flag in control key name
353353
&& !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
355355
}
356356
}
357357
settings.load(Object.keys(settings.controls))
@@ -379,7 +379,7 @@
379379
entryData.symbol || this.state.symbols[+settings.typeIsEnabled(key)] } ${entryData.label} ${
380380
entryData.type == 'toggle' ? this.state.separator
381381
+ this.state.words[+settings.typeIsEnabled(key)]
382-
: entryData.type == 'slider' ? ': ' + config[key] + entryData.labelSuffix || ''
382+
: entryData.type == 'slider' ? ': ' + app.config[key] + entryData.labelSuffix || ''
383383
: entryData.status ? ` — ${entryData.status}` : '' }`
384384
return GM_registerMenuCommand(menuLabel, () => {
385385
if (entryData.type == 'toggle') {
@@ -422,7 +422,7 @@
422422
// Define FEEDBACK functions
423423

424424
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
426426

427427
// Strip state word to append colored one later
428428
const foundState = toolbarMenu.state.words.find(word => msg.includes(word))
@@ -675,7 +675,7 @@
675675
}
676676

677677
function syncConfigToUI({ updatedKey } = {}) {
678-
if (updatedKey == 'autoclear' && config.autoclear) clearChatsAndGoHome()
678+
if (updatedKey == 'autoclear' && app.config.autoclear) clearChatsAndGoHome()
679679
if (/autoclear|toggleHidden/.test(updatedKey)) toggles.sidebar.update.state()
680680
toolbarMenu.refresh() // prefixes/suffixes
681681
}
@@ -709,7 +709,7 @@
709709
this.div.style.setProperty('--item-background-color',
710710
`var(--sidebar-surface-${ type == 'mouseover' ? 'secondary' : 'primary' })`)
711711
this.div.onclick = () => {
712-
settings.save('autoclear', !config.autoclear) ; syncConfigToUI({ updatedKey: 'autoclear' })
712+
settings.save('autoclear', !app.config.autoclear) ; syncConfigToUI({ updatedKey: 'autoclear' })
713713
notify(`${app.msgs.mode_autoclear}: ${toolbarMenu.state.words[+config.autoclear]}`)
714714
}
715715
},
@@ -819,8 +819,8 @@
819819

820820
state() {
821821
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
824824
toggles.sidebar.toggleLabel.textContent = `${app.msgs.mode_autoclear} `
825825
+ app.msgs[`state_${ isOn ? 'enabled' : 'disabled' }`]
826826
requestAnimationFrame(() => {
@@ -842,11 +842,11 @@
842842
toggles.sidebar.insert()
843843

844844
// AUTO-CLEAR on first visit if enabled
845-
if (config.autoclear) clearChatsAndGoHome()
845+
if (app.config.autoclear) clearChatsAndGoHome()
846846

847847
// Monitor NODE CHANGES to maintain sidebar toggle visibility
848848
new MutationObserver(() => {
849-
if (!config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar)
849+
if (!app.config.toggleHidden && document.querySelector(chatgpt.selectors.sidebar)
850850
&& !document.querySelector(`.${toggles.sidebar.class}`)
851851
&& toggles.sidebar.status != 'inserting'
852852
) { toggles.sidebar.status = 'missing' ; toggles.sidebar.insert() }

0 commit comments

Comments
 (0)