mirror of
https://github.com/danbulant/dribbblish-dynamic-theme
synced 2026-05-24 12:35:05 +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 coverListenerInstalled = true;
|
||||
let coverListenerInstalled = false;
|
||||
async function songchange() {
|
||||
try {
|
||||
// warning popup
|
||||
|
|
@ -409,20 +409,19 @@ waitForElement([".main-nowPlayingBar-left"], (queries) => {
|
|||
function hookCoverChange(pick) {
|
||||
waitForElement([".cover-art-image"], (queries) => {
|
||||
coverListenerInstalled = true;
|
||||
if (pick && queries[0].complete && queries[0].naturalHeight !== 0) pickCoverColor(queries[0]);
|
||||
queries[0].addEventListener("load", function () {
|
||||
var elem = queries.slice(-1)[0];
|
||||
if (pick && elem.complete && elem.naturalHeight !== 0) pickCoverColor(elem);
|
||||
elem.addEventListener("load", function () {
|
||||
try {
|
||||
pickCoverColor(queries[0]);
|
||||
pickCoverColor(elem);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setTimeout(pickCoverColor, 300, queries[0]);
|
||||
setTimeout(pickCoverColor, 300, elem);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookCoverChange(false);
|
||||
|
||||
(function Startup() {
|
||||
if (!Spicetify.showNotification) {
|
||||
setTimeout(Startup, 300);
|
||||
|
|
|
|||
Loading…
Reference in a new issue