Skip to content

Commit

Permalink
#4
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoOliveira committed Jan 23, 2024
1 parent 601fd95 commit d2fbce8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
}

await init()

0 comments on commit d2fbce8

Please sign in to comment.