Skip to content

Commit

Permalink
Fix typos and refactor if-statement hell
Browse files Browse the repository at this point in the history
  • Loading branch information
acquitelol committed Nov 26, 2023
1 parent 818f7ab commit b3d27ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<hr />
- Extract the ZIP to a folder onto your local file system.
- Open the **Manage Extensions** tab in your Chromium-based browser
- (This can be any browser ranging from `Chrome` to `Edge` to `Opera` to `Arc`).
- (This can be any browser ranging from `Chrome` to `Edge` to `Opera` to `Arc` to `Orion`).
<hr />
- *(Enable* ***Developer Mode*** *if not enabled already.)*
- Click on **Load Unpacked**.
- Select the **Azalea-(version)** directory.
<hr />
- **You're done!** Open/Refresh `Sparx` the extension should be installed! :D
- **You're done!** Open/Refresh `Sparx` and the extension should be installed! :D

<img src="extension/assets/divider.png">

Expand Down Expand Up @@ -49,7 +49,7 @@

<hr />

- Allows you to change the icon usd in Sparx by providing an image URL! (editable from **Menu > Settings**, off by default).
- Allows you to change the icon used in Sparx by providing an image URL! (editable from **Menu > Settings**, off by default).

<img src="extension/assets/divider.png">

Expand Down
67 changes: 34 additions & 33 deletions src/loader/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,39 +61,40 @@ chrome.runtime.onMessage.addListener(async (message, sender) => {
if (typeof message !== 'object') return;
const { type, update, reset, local } = message;

if (type === 'inject-azalea') {
if (local) {
console.info('Loading bundle from local sources...');

const res = await fetch(chrome.runtime.getURL('bundle.js'))
.then(r => r.text())
.catch(() => {
console.info('Bundle doesn\'t exist! Assuming enabling local mode was a mistake...')
})

res && inject(sender.tab.id, res);
} else {
if (reset) {
console.info('Clearing bundle and hash! Please wait...');
await chrome.storage.local.set({ azaleaHash: null, azalea: null })
}

const loader = await fetch(chrome.runtime.getURL('loader.js')).then(r => r.text());
const { azalea } = await promisifiedGet('azalea');

if (azalea) {
inject(
sender.tab.id,
loader.replace('INJECT_AZALEA_SOURCE', azalea),
);
}

if (update) {
console.info('Updates are disabled.')
} else {
await updateAzalea(sender.tab.id);
}
}
if (type !== 'inject-azalea') return;

if (local) {
console.info('Loading bundle from local sources...');

const res = await fetch(chrome.runtime.getURL('bundle.js'))
.then(r => r.text())
.catch(() => {
console.info('Bundle doesn\'t exist! Assuming enabling local mode was a mistake...')
})

res && inject(sender.tab.id, res);
return;
}

if (reset) {
console.info('Clearing bundle and hash! Please wait...');
await chrome.storage.local.set({ azaleaHash: null, azalea: null })
}

const loader = await fetch(chrome.runtime.getURL('loader.js')).then(r => r.text());
const { azalea } = await promisifiedGet('azalea');

if (azalea) {
inject(
sender.tab.id,
loader.replace('INJECT_AZALEA_SOURCE', azalea),
);
}

if (update) {
console.info('Updates are disabled.')
} else {
await updateAzalea(sender.tab.id);
}
} catch (e) {
throw new Error('Failed to load Azalea: ' + e);
Expand Down

0 comments on commit b3d27ab

Please sign in to comment.