Skip to content

Commit

Permalink
Un-moduleized lib/settings.mjs to align w/ other libs ↞ [auto-sync from
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Dec 1, 2024
1 parent 1486caa commit 33569d4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion starters/chrome/extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
(async () => {

// Import LIBS
const { config, settings } = await import(chrome.runtime.getURL('lib/settings.mjs'))
await import(chrome.runtime.getURL('lib/chatgpt.js'))
await import(chrome.runtime.getURL('lib/settings.js'))

// Import APP data
const { app } = await chrome.storage.sync.get('app')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const config = {}, settings = {
window.config = {}
window.settings = {

// Init SETTINGS props (for popup menu)
controls: {
Expand All @@ -18,14 +19,12 @@ const config = {}, settings = {
Array.isArray(arguments[0]) ? arguments[0] : Array.from(arguments))
return Promise.all(keys.map(key => // resolve promise when all keys load
new Promise(resolve => // resolve promise when single key value loads
chrome.storage.sync.get(key, result => { // load from Chrome
config[key] = result[key] || false ; resolve()
chrome.storage.sync.get(key, result => { // load from Chrome extension storage
window.config[key] = result[key] || false ; resolve()
}))))},

save(key, val) {
chrome.storage.sync.set({ [key]: val }) // save to Chrome
config[key] = val // save to memory
chrome.storage.sync.set({ [key]: val }) // save to Chrome extension storage
window.config[key] = val // save to memory
}
}

export { config, settings }
2 changes: 1 addition & 1 deletion starters/chrome/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"action": { "default_popup": "popup/index.html" },
"web_accessible_resources": [{
"matches": [ "<all_urls>" ],
"resources": [ "lib/settings.mjs", "lib/chatgpt.js" ]
"resources": [ "lib/settings.js", "lib/chatgpt.js" ]
}],
"content_scripts": [{
"matches": [ "https://chatgpt.com/*" ],
Expand Down
2 changes: 1 addition & 1 deletion starters/chrome/extension/popup/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// Import LIBS
await import(chrome.runtime.getURL('lib/dom.js'))
const { config, settings } = await import(chrome.runtime.getURL('lib/settings.mjs'))
await import(chrome.runtime.getURL('lib/settings.mjs'))

// Ipmort APP data
const { app } = await chrome.storage.sync.get('app')
Expand Down

0 comments on commit 33569d4

Please sign in to comment.