From 97b1af88ca2827afa75b64ae2e9deda81b9c2bb5 Mon Sep 17 00:00:00 2001 From: KayoticCarnige <32397453+kckarnige@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:10:13 -0500 Subject: [PATCH] Fixed icon not showing properly sometimes --- SECURITY.md | 2 +- manifest.crx.json | 2 +- manifest.xpi.json | 2 +- src/res/js/index.js | 12 +++++++----- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 5b3d8c8..47e7760 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1 +1 @@ -No user information is collected in any capacity, it it shall remain that way. +No user information is collected in any capacity, and it shall remain that way. diff --git a/manifest.crx.json b/manifest.crx.json index 14fcb65..5f106b4 100644 --- a/manifest.crx.json +++ b/manifest.crx.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "Ecsta", "short_name": "Ecsta", - "version": "0.3.3", + "version": "0.3.4", "description": "A simple new tab extension meant to stay out of your way while still making for great eye-candy.", diff --git a/manifest.xpi.json b/manifest.xpi.json index 7fd78bf..4bef72f 100644 --- a/manifest.xpi.json +++ b/manifest.xpi.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Ecsta", "short_name": "Ecsta", - "version": "0.3.3", + "version": "0.3.4", "description": "A simple new tab extension meant to stay out of your way while still making for great eye-candy.", diff --git a/src/res/js/index.js b/src/res/js/index.js index d867cf6..b097e3d 100644 --- a/src/res/js/index.js +++ b/src/res/js/index.js @@ -3,6 +3,13 @@ const getLastFetchDate = localStorage.getItem("lastFetchDate"); const UNSPLASH_API_KEY = localStorage.getItem("unsplashApiKey"); var currentDate = new Date().toISOString().split("T")[0]; +window.onload = () => { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.getElementById("tabIcon").setAttribute("href","res/icons/white-256.png") + } else { + document.getElementById("tabIcon").setAttribute("href","res/icons/black-256.png") + } +} if (UNSPLASH_API_KEY) { //Background code function set(fetched) { @@ -65,11 +72,6 @@ if (UNSPLASH_API_KEY) { document.getElementById("imgCreator").innerText = ("Image by " + localStorage.getItem("unsplashApiCreditName")); document.getElementById("imgCreator").setAttribute("href", localStorage.getItem("unsplashApiCreditLink")); } - if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { - document.getElementById("tabIcon").setAttribute("href","res/icons/white-256.png") - } else { - document.getElementById("tabIcon").setAttribute("href","res/icons/black-256.png") - } console.log( `Hasn't been 3 minutes (Has only been ${( Date.now() / 60000 -