Skip to content

Commit 33569d4

Browse files
committed
Un-moduleized lib/settings.mjs to align w/ other libs ↞ [auto-sync from https://github.com/KudoAI/chatgpt.js-chrome-starter]
1 parent 1486caa commit 33569d4

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

starters/chrome/extension/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
(async () => {
55

66
// Import LIBS
7-
const { config, settings } = await import(chrome.runtime.getURL('lib/settings.mjs'))
87
await import(chrome.runtime.getURL('lib/chatgpt.js'))
8+
await import(chrome.runtime.getURL('lib/settings.js'))
99

1010
// Import APP data
1111
const { app } = await chrome.storage.sync.get('app')

starters/chrome/extension/lib/settings.mjs renamed to starters/chrome/extension/lib/settings.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const config = {}, settings = {
1+
window.config = {}
2+
window.settings = {
23

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

2526
save(key, val) {
26-
chrome.storage.sync.set({ [key]: val }) // save to Chrome
27-
config[key] = val // save to memory
27+
chrome.storage.sync.set({ [key]: val }) // save to Chrome extension storage
28+
window.config[key] = val // save to memory
2829
}
2930
}
30-
31-
export { config, settings }

starters/chrome/extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"action": { "default_popup": "popup/index.html" },
1717
"web_accessible_resources": [{
1818
"matches": [ "<all_urls>" ],
19-
"resources": [ "lib/settings.mjs", "lib/chatgpt.js" ]
19+
"resources": [ "lib/settings.js", "lib/chatgpt.js" ]
2020
}],
2121
"content_scripts": [{
2222
"matches": [ "https://chatgpt.com/*" ],

starters/chrome/extension/popup/controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
// Import LIBS
77
await import(chrome.runtime.getURL('lib/dom.js'))
8-
const { config, settings } = await import(chrome.runtime.getURL('lib/settings.mjs'))
8+
await import(chrome.runtime.getURL('lib/settings.mjs'))
99

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

0 commit comments

Comments
 (0)