improve million application

This commit is contained in:
SethBurkart123
2024-03-24 09:45:27 +11:00
parent a0d710f22c
commit e1467782b0
10 changed files with 39 additions and 41 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
import browser from 'webextension-polyfill';
import { SettingsState } from '../../types/storage';
import backgroundURL from './background/background.html?url'
export async function appendBackgroundToUI() {
const settings = await browser.storage.local.get() as SettingsState;
@@ -13,6 +14,6 @@ export async function appendBackgroundToUI() {
background.id = 'background';
background.classList.add('imageBackground');
background.setAttribute('excludeDarkCheck', 'true');
background.src = browser.runtime.getURL('src/seqta/ui/background/background.html');
background.src = browser.runtime.getURL(backgroundURL);
parent!.appendChild(background);
}
+1 -1
View File
@@ -24,6 +24,6 @@
<!-- Container for the media -->
<div id="media-container"></div>
<script src="./background.ts"></script>
<script type="module" src="./background.ts"></script>
</body>
</html>
+12 -7
View File
@@ -99,14 +99,19 @@ const updateBackground = async (): Promise<void> => {
// Main function to run on page load
const main = async (): Promise<void> => {
await updateBackground();
// Listen for changes to local storage
window.addEventListener('storage', async (event) => {
if (event.key === 'selectedBackground') {
await updateBackground();
}
});
try {
window.addEventListener('storage', async (event) => {
if (event.key === 'selectedBackground') {
await updateBackground();
}
});
} catch (error) {
console.log('An error occurred:', error);
}
};
main()
// Run the main function when the document is ready
document.addEventListener('DOMContentLoaded', main);
//document.addEventListener('DOMContentLoaded', main);