push new update, + Notices UI fixes

This commit is contained in:
SethBurkart123
2023-11-24 17:19:11 +11:00
parent 8c9d36f4d6
commit 9527853606
58 changed files with 499 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Background Fetcher</title>
<style>
body {
margin: 0 !important;
}
video, img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
</head>
<body>
<!-- Container for the media -->
<div id="media-container">
<!-- Will be populated dynamically -->
</div>
<script src="background.js"></script>
</body>
</html>
+1
View File
@@ -0,0 +1 @@
const openDB=()=>new Promise(((e,t)=>{const o=indexedDB.open("MyDatabase",1);o.onerror=()=>t(o.error),o.onsuccess=()=>e(o.result),o.onupgradeneeded=e=>{e.target.result.createObjectStore("backgrounds",{keyPath:"id"})}})),readData=async()=>{const e=localStorage.getItem("selectedBackground");if(!e)return console.log("No selected background in local storage."),null;const t=(await openDB()).transaction("backgrounds","readonly").objectStore("backgrounds").get(e);return await new Promise(((e,o)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>o(t.error)}))},updateBackground=async()=>{try{const e=await readData();if(!e){console.log("No data found in IndexedDB.");const e=document.getElementById("media-container").querySelector(".current-media");return void(e&&e.remove())}const t=URL.createObjectURL(e.blob),o=document.getElementById("media-container");let a;"image"===e.type?(a=document.createElement("img"),a.src=t,a.alt="Uploaded content"):"video"===e.type&&(a=document.createElement("video"),a.src=t,a.autoplay=!0,a.loop=!0,a.muted=!0);const r=o.querySelector(".current-media");r&&(r.classList.remove("current-media"),r.classList.add("old-media")),a.classList.add("current-media"),o.appendChild(a),setTimeout((()=>{const e=o.querySelector(".old-media");e&&e.remove()}),100)}catch(e){console.error("An error occurred:",e)}},main=async()=>{await updateBackground(),window.addEventListener("storage",(async e=>{"selectedBackground"===e.key&&await updateBackground()}))};document.addEventListener("DOMContentLoaded",main);