diff --git a/starters/chrome/extension/content.js b/starters/chrome/extension/content.js index 1d2da424a..c57431885 100644 --- a/starters/chrome/extension/content.js +++ b/starters/chrome/extension/content.js @@ -18,7 +18,7 @@ }) // Init CONFIG - await settings.load(Object.keys(settings.props), 'skipAlert') + await settings.load(Object.keys(settings.controls), 'skipAlert') // Define FEEDBACK functions @@ -49,11 +49,11 @@ // Define SYNC function async function syncStorageToUI() { // on toolbar popup toggles + ChatGPT tab activations - await settings.load('extensionDisabled', Object.keys(settings.props)) // load from Chrome storage to content.js config + await settings.load('extensionDisabled', Object.keys(settings.controls)) // load from Chrome storage to content.js config if (config.extensionDisabled) { // Remove all hacks } else { - // Add/remove hacks to reflect each potentially updated setting per settings.props in lib/settings.js + // Add/remove hacks to reflect each potentially updated setting per settings.controls in lib/settings.js // e.g. if you created toolbar popup toggle to hide ChatGPT footer using hiddenFooter key... // ...here you would use config.hiddenFooter to conditionally append/remove hidden footer style... // ...(initial style creation + append if config.hiddenFooter would go in main routine) diff --git a/starters/chrome/extension/lib/settings.js b/starters/chrome/extension/lib/settings.js index aab8969b1..21ca64486 100644 --- a/starters/chrome/extension/lib/settings.js +++ b/starters/chrome/extension/lib/settings.js @@ -1,7 +1,7 @@ const config = {}, settings = { // Init SETTINGS props (for popup menu) - props: { + controls: { // Add settings options as keys, with each key's value being an object that includes: // - 'type': the control type (e.g. 'toggle' or 'prompt') // - 'label': a descriptive label diff --git a/starters/chrome/extension/popup/controller.js b/starters/chrome/extension/popup/controller.js index 43319d4b3..79884ab00 100644 --- a/starters/chrome/extension/popup/controller.js +++ b/starters/chrome/extension/popup/controller.js @@ -67,22 +67,22 @@ document.querySelector('.menu-header').insertAdjacentElement('afterend', togglesDiv) // Create/insert settings toggles - Object.keys(settings.props).forEach(key => { + Object.keys(settings.controls).forEach(key => { // Init elems const menuItemDiv = dom.create.elem('div', { class: 'menu-item menu-area' }), menuLabel = dom.create.elem('label', { class: 'menu-icon' }), menuLabelSpan = document.createElement('span') let menuInput, menuSlider - menuLabelSpan.textContent = settings.props[key].label - if (settings.props[key].type == 'toggle') { + menuLabelSpan.textContent = settings.controls[key].label + if (settings.controls[key].type == 'toggle') { menuInput = dom.create.elem('input', { type: 'checkbox' }) menuInput.checked = /disabled|hidden/i.test(key) ^ config[key] menuSlider = dom.create.elem('span', { class: 'slider' }) menuLabel.append(menuInput, menuSlider) menuLabel.classList.add('toggle-switch') - } else if (settings.props[key].type == 'prompt') { - menuLabel.innerText = settings.props[key].symbol + } else if (settings.controls[key].type == 'prompt') { + menuLabel.innerText = settings.controls[key].symbol menuLabel.classList.add('menu-prompt') } @@ -91,15 +91,15 @@ togglesDiv.append(menuItemDiv) // Add listeners - if (settings.props[key].type == 'toggle') { + if (settings.controls[key].type == 'toggle') { menuItemDiv.onclick = () => menuInput.click() menuInput.onclick = menuSlider.onclick = event => // prevent double toggle event.stopImmediatePropagation() menuInput.onchange = () => { settings.save(key, !config[key]) ; sync.storageToUI() - notify(`${settings.props[key].label} ${ /disabled|hidden/i.test(key) != config[key] ? 'ON' : 'OFF' }`) + notify(`${settings.controls[key].label} ${ /disabled|hidden/i.test(key) != config[key] ? 'ON' : 'OFF' }`) } - } else if (settings.props[key].type == 'prompt') { + } else if (settings.controls[key].type == 'prompt') { // custom logic for each prompt based on key name } })