2021-08-13 21:22:47 +02:00
|
|
|
(function fluent() {
|
|
|
|
|
|
|
|
function waitForElement(els, func, timeout = 10000) {
|
|
|
|
const queries = els.map(el => document.querySelector(el));
|
|
|
|
if (queries.every(a => a)) {
|
|
|
|
func();
|
|
|
|
} else if (timeout > 0) {
|
|
|
|
setTimeout(waitForElement, 300, els, func, timeout--);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
waitForElement([
|
2021-09-16 16:05:55 +02:00
|
|
|
".main-rootlist-rootlistItemLink"
|
|
|
|
], function () {
|
2021-08-13 21:22:47 +02:00
|
|
|
function replacePlaylistIcons() {
|
2021-09-16 16:05:55 +02:00
|
|
|
const playListItems = document.getElementsByClassName("main-rootlist-rootlistItemLink");
|
2021-08-13 21:22:47 +02:00
|
|
|
|
2021-09-16 16:05:55 +02:00
|
|
|
for (const item of playListItems) {
|
|
|
|
const link = item.pathname;
|
2021-08-13 21:22:47 +02:00
|
|
|
let uri;
|
2021-09-16 16:05:55 +02:00
|
|
|
if (link.search("playlist") !== -1) {
|
|
|
|
uri = Spicetify.URI.playlistV2URI(link.split("/").pop());
|
|
|
|
} else if (link.search("folder") !== -1) {
|
2021-10-03 19:32:55 +02:00
|
|
|
item.style.content = "url('./fluentui-system-icons/ic_fluent_folder_24_filled.svg')"
|
2021-08-13 21:22:47 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Spicetify.CosmosAsync.get(
|
2021-09-16 16:05:55 +02:00
|
|
|
`sp://core-playlist/v1/playlist/${uri.toString()}/metadata`, {
|
|
|
|
policy: {
|
|
|
|
picture: true
|
2021-08-13 21:22:47 +02:00
|
|
|
}
|
2021-09-16 16:05:55 +02:00
|
|
|
}
|
2021-08-13 21:22:47 +02:00
|
|
|
).then(res => {
|
|
|
|
const meta = res.metadata;
|
2021-09-16 16:05:55 +02:00
|
|
|
if (meta.picture === "") {
|
2021-10-03 19:32:55 +02:00
|
|
|
item.style.content = "url('./fluentui-system-icons/ic_fluent_music_note_2_24_filled.svg')"
|
2021-08-13 21:22:47 +02:00
|
|
|
} else {
|
2021-09-16 16:05:55 +02:00
|
|
|
item.style.backgroundImage = "url(" + meta.picture + ")";
|
|
|
|
item.style.content = "";
|
2021-08-13 21:22:47 +02:00
|
|
|
}
|
|
|
|
});
|
2021-09-16 16:05:55 +02:00
|
|
|
};
|
2021-10-02 07:41:42 +02:00
|
|
|
|
2021-08-13 21:22:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
replacePlaylistIcons();
|
|
|
|
const observer = new MutationObserver(replacePlaylistIcons);
|
2021-10-02 07:41:42 +02:00
|
|
|
waitForElement(["#spicetify-playlist-list"], () => {
|
|
|
|
const rootList = document.querySelector("#spicetify-playlist-list");
|
2021-09-16 16:05:55 +02:00
|
|
|
observer.observe(rootList, {
|
|
|
|
childList: true,
|
|
|
|
subtree: true
|
|
|
|
});
|
2021-08-13 21:22:47 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
waitForElement([
|
2021-09-16 16:05:55 +02:00
|
|
|
".main-navBar-navBarLink",
|
|
|
|
"[href='/collection'] > span"
|
|
|
|
], () => {
|
|
|
|
const navBarItems = document.getElementsByClassName("main-navBar-navBarLink");
|
|
|
|
for (const item of navBarItems) {
|
2021-08-13 21:22:47 +02:00
|
|
|
let div = document.createElement("div");
|
|
|
|
div.classList.add("navBar-navBarLink-accent");
|
2021-09-16 16:05:55 +02:00
|
|
|
item.appendChild(div);
|
2021-08-13 21:22:47 +02:00
|
|
|
}
|
2021-09-16 16:05:55 +02:00
|
|
|
document.querySelector("[href='/collection'] > span").innerHTML = "Library";
|
2021-08-13 21:22:47 +02:00
|
|
|
});
|
|
|
|
|
2021-09-16 16:05:55 +02:00
|
|
|
const textColor = getComputedStyle(document.documentElement).getPropertyValue('--spice-text');
|
|
|
|
if (textColor == " #000000") {
|
2021-08-13 21:22:47 +02:00
|
|
|
document.documentElement.style.setProperty('--filter-brightness', 0);
|
|
|
|
}
|
2021-10-02 07:41:42 +02:00
|
|
|
|
|
|
|
var interval = setInterval(function() {
|
|
|
|
if(typeof Spicetify.Platform.Translations.play == 'undefined' && typeof Spicetify.Platform.Translations.pause == 'undefined') return;
|
|
|
|
clearInterval(interval);
|
|
|
|
var playButtonStyle = document.createElement('style');
|
|
|
|
playButtonStyle.type = 'text/css';
|
|
|
|
playButtonStyle.innerHTML = `
|
|
|
|
.main-playButton-button[aria-label="${Spicetify.Platform.Translations.play}"],
|
|
|
|
.main-playButton-PlayButton[aria-label="${Spicetify.Platform.Translations.play}"],
|
|
|
|
.main-playPauseButton-button[aria-label="${Spicetify.Platform.Translations.play}"],
|
|
|
|
.main-trackList-rowPlayPauseButton[aria-label="${Spicetify.Platform.Translations.play}"] {
|
|
|
|
background-color: var(--spice-text) !important;
|
|
|
|
-webkit-mask-image: url('./fluentui-system-icons/ic_fluent_play_24_filled.svg') !important;
|
|
|
|
}
|
|
|
|
.main-playButton-button[aria-label="${Spicetify.Platform.Translations.pause}"],
|
|
|
|
.main-playButton-PlayButton[aria-label="${Spicetify.Platform.Translations.pause}"],
|
|
|
|
.main-playPauseButton-button[aria-label="${Spicetify.Platform.Translations.pause}"],
|
|
|
|
.main-trackList-rowPlayPauseButton[aria-label="${Spicetify.Platform.Translations.pause}"] {
|
|
|
|
background-color: var(--spice-text) !important;
|
|
|
|
-webkit-mask-image: url('./fluentui-system-icons/ic_fluent_pause_16_filled.svg') !important;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
document.getElementsByTagName('head')[0].appendChild(playButtonStyle);
|
|
|
|
}, 10)
|
2021-08-13 21:22:47 +02:00
|
|
|
|
|
|
|
})();
|