mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-25 04:52:10 +00:00
cleaner way to hook the cover change function
This commit is contained in:
parent
299503c426
commit
611907a2d6
1 changed files with 6 additions and 7 deletions
|
|
@ -311,7 +311,7 @@ function updateColors(textColHex, sideColHex, checkDarkMode = true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let nearArtistSpanText = "";
|
let nearArtistSpanText = "";
|
||||||
let coverListenerInstalled = true;
|
let coverListenerInstalled = false;
|
||||||
async function songchange() {
|
async function songchange() {
|
||||||
try {
|
try {
|
||||||
// warning popup
|
// warning popup
|
||||||
|
|
@ -409,20 +409,19 @@ waitForElement([".main-nowPlayingBar-left"], (queries) => {
|
||||||
function hookCoverChange(pick) {
|
function hookCoverChange(pick) {
|
||||||
waitForElement([".cover-art-image"], (queries) => {
|
waitForElement([".cover-art-image"], (queries) => {
|
||||||
coverListenerInstalled = true;
|
coverListenerInstalled = true;
|
||||||
if (pick && queries[0].complete && queries[0].naturalHeight !== 0) pickCoverColor(queries[0]);
|
var elem = queries.slice(-1)[0];
|
||||||
queries[0].addEventListener("load", function () {
|
if (pick && elem.complete && elem.naturalHeight !== 0) pickCoverColor(elem);
|
||||||
|
elem.addEventListener("load", function () {
|
||||||
try {
|
try {
|
||||||
pickCoverColor(queries[0]);
|
pickCoverColor(elem);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
setTimeout(pickCoverColor, 300, queries[0]);
|
setTimeout(pickCoverColor, 300, elem);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
hookCoverChange(false);
|
|
||||||
|
|
||||||
(function Startup() {
|
(function Startup() {
|
||||||
if (!Spicetify.showNotification) {
|
if (!Spicetify.showNotification) {
|
||||||
setTimeout(Startup, 300);
|
setTimeout(Startup, 300);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue