diff --git a/starters/chrome/extension/content.js b/starters/chrome/extension/content.js index cbc2feebb..e3fa08c7c 100644 --- a/starters/chrome/extension/content.js +++ b/starters/chrome/extension/content.js @@ -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') diff --git a/starters/chrome/extension/lib/settings.mjs b/starters/chrome/extension/lib/settings.js similarity index 84% rename from starters/chrome/extension/lib/settings.mjs rename to starters/chrome/extension/lib/settings.js index 034e8e30b..c9ec20cfe 100644 --- a/starters/chrome/extension/lib/settings.mjs +++ b/starters/chrome/extension/lib/settings.js @@ -1,4 +1,5 @@ -const config = {}, settings = { +window.config = {} +window.settings = { // Init SETTINGS props (for popup menu) controls: { @@ -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 } diff --git a/starters/chrome/extension/manifest.json b/starters/chrome/extension/manifest.json index d88ae0dd6..e02d603fd 100644 --- a/starters/chrome/extension/manifest.json +++ b/starters/chrome/extension/manifest.json @@ -16,7 +16,7 @@ "action": { "default_popup": "popup/index.html" }, "web_accessible_resources": [{ "matches": [ "" ], - "resources": [ "lib/settings.mjs", "lib/chatgpt.js" ] + "resources": [ "lib/settings.js", "lib/chatgpt.js" ] }], "content_scripts": [{ "matches": [ "https://chatgpt.com/*" ], diff --git a/starters/chrome/extension/popup/controller.js b/starters/chrome/extension/popup/controller.js index 44e931283..2fed83597 100644 --- a/starters/chrome/extension/popup/controller.js +++ b/starters/chrome/extension/popup/controller.js @@ -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')