From d2fbce86e3553dc1f7c17882fdfd49cbaead4eb0 Mon Sep 17 00:00:00 2001 From: Eduardo Oliveira Date: Tue, 23 Jan 2024 15:30:15 +0000 Subject: [PATCH] #4 --- main.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index 1f4a5c0..4313d3f 100644 --- a/main.js +++ b/main.js @@ -9,6 +9,12 @@ let settings = null; const init = async () => { console.log(settings) const tabs = await chrome.tabs.query({ active: true }) + for (const i in tabs) { + if (tabs[i].title === "MMP - Maker Management Platform") { + await showInit() + return + } + } for (const i in tabs) { const url = new URL(tabs[i].url); if (supportedSites.includes(url.origin)) { @@ -44,6 +50,9 @@ const showInit = async () => { const url = new URL(tabs[i].url); const response = await fetch(url.origin + '/settings.json') settings = await response.json(); + if (settings.local_backend.startsWith("/")) { + settings.local_backend = url.origin + settings.local_backend + } await chrome.storage.sync.set({ settings }) init() } @@ -124,9 +133,9 @@ actions.show['https://www.thingiverse.com'] = async () => { const mmpBackendStorage = await chrome.storage.sync.get("settings") console.log(mmpBackendStorage) -if (!mmpBackendStorage.settings) { - await showInit() -} else { + +if (mmpBackendStorage.settings) { settings = mmpBackendStorage.settings - await init() -} \ No newline at end of file +} + +await init() \ No newline at end of file