2020-08-08 21:09:25 +02:00
|
|
|
// Hide popover message
|
|
|
|
document.getElementById("popover-container").style.height = 0;
|
|
|
|
|
2020-12-08 12:03:53 +01:00
|
|
|
// Get stored hidden sidebar list
|
|
|
|
let appHiddenList = [];
|
|
|
|
try {
|
|
|
|
const rawList = JSON.parse(localStorage.getItem("sidebar-app-hide-list"));
|
|
|
|
if (!Array.isArray(rawList)) throw 0;
|
|
|
|
appHiddenList.push(...rawList);
|
|
|
|
} catch {
|
|
|
|
localStorage.setItem("sidebar-app-hide-list", "[]")
|
|
|
|
}
|
|
|
|
|
|
|
|
new Spicetify.ContextMenu.Item(
|
|
|
|
"Hide",
|
|
|
|
([uri]) => {
|
|
|
|
appHiddenList.push(uri.replace("spotify:special:sidebarapp:", ""));
|
|
|
|
localStorage.setItem("sidebar-app-hide-list", JSON.stringify(appHiddenList));
|
|
|
|
window.location.reload();
|
|
|
|
},
|
|
|
|
([uri]) => uri.startsWith("spotify:special:sidebarapp:")
|
|
|
|
).register();
|
|
|
|
|
|
|
|
for (const app of appHiddenList) {
|
|
|
|
new Spicetify.ContextMenu.Item(
|
|
|
|
"Show " + app.replace("spotify:app:", ""),
|
|
|
|
() => {
|
|
|
|
appHiddenList = appHiddenList.filter(item => item !== app);
|
|
|
|
localStorage.setItem("sidebar-app-hide-list", JSON.stringify(appHiddenList));
|
|
|
|
window.location.reload();
|
|
|
|
},
|
|
|
|
([uri]) => uri.startsWith("spotify:special:sidebarapp:")
|
|
|
|
).register();
|
|
|
|
}
|
|
|
|
|
2020-07-05 13:28:41 +02:00
|
|
|
function waitForElement(els, func, timeout = 100) {
|
2020-05-06 11:55:08 +02:00
|
|
|
const queries = els.map(el => document.querySelector(el));
|
|
|
|
if (queries.every(a => a)) {
|
|
|
|
func(queries);
|
2020-07-05 13:28:41 +02:00
|
|
|
} else if (timeout > 0) {
|
|
|
|
setTimeout(waitForElement, 300, els, func, --timeout);
|
2020-05-06 11:55:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add "Open User Profile" item in profile menu
|
|
|
|
new Spicetify.Menu.Item(window.__spotify.username, false, () => window.open(window.__spotify.userUri)).register();
|
|
|
|
|
2020-05-10 15:35:55 +02:00
|
|
|
waitForElement([".LeftSidebar", ".LeftSidebar__section--rootlist .SidebarList__list"], (queries) => {
|
2020-05-06 11:55:08 +02:00
|
|
|
/** Replace Playlist name with their pictures */
|
2020-05-10 15:35:55 +02:00
|
|
|
function loadPlaylistImage() {
|
|
|
|
const sidebarItem = queries[1].childNodes;
|
|
|
|
|
|
|
|
for (let i = 0; i < sidebarItem.length; i++) {
|
|
|
|
const item = sidebarItem[i];
|
2020-07-05 13:28:41 +02:00
|
|
|
let link = item.getElementsByTagName("a");
|
|
|
|
if (!link || !link[0]) continue;
|
|
|
|
link = link[0];
|
|
|
|
|
2020-08-05 20:24:44 +02:00
|
|
|
let href = link.href.replace("app:", "");
|
2020-05-10 15:35:55 +02:00
|
|
|
|
|
|
|
if (href.indexOf("playlist-folder") != -1) {
|
|
|
|
const button = item.getElementsByTagName("button")[0]
|
|
|
|
button.classList.add("Button", "Button--style-icon-background", "Button--size-28",);
|
|
|
|
item.setAttribute("data-tooltip", item.innerText);
|
|
|
|
link.firstChild.innerText = item.innerText.slice(0, 3);
|
|
|
|
continue;
|
2020-05-06 11:55:08 +02:00
|
|
|
}
|
|
|
|
|
2020-08-05 20:24:44 +02:00
|
|
|
if (href.indexOf("chart") != -1) {
|
|
|
|
href = href.replace("chart:", "user:spotifycharts:playlist:");
|
|
|
|
}
|
|
|
|
|
2020-05-10 15:35:55 +02:00
|
|
|
Spicetify.CosmosAPI.resolver.get({
|
|
|
|
url: `sp://core-playlist/v1/playlist/${href}/metadata`,
|
2020-05-19 15:12:55 +02:00
|
|
|
body: { policy: { picture: true } },
|
2020-05-10 15:35:55 +02:00
|
|
|
}, (err, res) => {
|
|
|
|
if (err) return;
|
|
|
|
const meta = res.getJSONBody().metadata;
|
|
|
|
item.firstChild.className = "playlist-picture"
|
|
|
|
item.firstChild.style.backgroundImage = `url(${meta.picture})`;
|
2020-05-19 15:12:55 +02:00
|
|
|
item.firstChild.setAttribute("data-tooltip", item.textContent);
|
2020-05-10 15:35:55 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loadPlaylistImage();
|
|
|
|
|
|
|
|
new MutationObserver(loadPlaylistImage)
|
|
|
|
.observe(queries[1], {childList: true});
|
2020-08-05 20:24:44 +02:00
|
|
|
|
2020-05-06 11:55:08 +02:00
|
|
|
/** Replace Apps name with icons */
|
|
|
|
|
|
|
|
/** List of avaiable icons to use:
|
|
|
|
addfollow filter more skipforward15
|
|
|
|
addfollowers flag newradio sort
|
|
|
|
addsuggestedsong follow notifications sortdown
|
|
|
|
album fullscreen offline sortup
|
|
|
|
artist gears pause spotifylogo
|
|
|
|
attach headphones play star
|
|
|
|
block heart playlist stations
|
|
|
|
bluetooth helpcircle plus subtitles
|
|
|
|
browse home podcasts tag
|
|
|
|
camera inbox queue time
|
|
|
|
check instagram radio track
|
|
|
|
collection lightning refresh trending
|
|
|
|
copy localfile released user
|
|
|
|
devices locked repeat video
|
|
|
|
discover lyrics repeatonce volume
|
|
|
|
download menu search watch
|
|
|
|
downloaded messages share x
|
|
|
|
edit mic shuffle helpcircle
|
|
|
|
email minimise skip
|
|
|
|
events mix skipback15
|
|
|
|
*/
|
|
|
|
|
2020-07-05 13:28:41 +02:00
|
|
|
function replaceTextWithIcon(el, iconName) {
|
2020-12-08 12:03:53 +01:00
|
|
|
const href = el.parentNode.href;
|
|
|
|
if (appHiddenList.indexOf(href) !== -1) {
|
|
|
|
let parent = el;
|
|
|
|
while (parent.tagName !== "LI") {
|
|
|
|
parent = parent.parentNode;
|
|
|
|
}
|
|
|
|
parent.remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-08 21:09:25 +02:00
|
|
|
if (iconName) {
|
|
|
|
el.classList.add(`spoticon-${iconName}-24`);
|
|
|
|
}
|
|
|
|
|
|
|
|
el.parentNode.setAttribute("data-tooltip", el.innerText);
|
2020-12-08 12:03:53 +01:00
|
|
|
el.parentNode.setAttribute("data-contextmenu", "");
|
|
|
|
el.parentNode.setAttribute("data-uri", "spotify:special:sidebarapp:" + href);
|
2020-07-05 13:28:41 +02:00
|
|
|
el.innerText = "";
|
|
|
|
}
|
|
|
|
|
2020-05-06 11:55:08 +02:00
|
|
|
queries[0].querySelectorAll(".LeftSidebar__section:not(.LeftSidebar__section--rootlist) [href]")
|
|
|
|
.forEach(item => {
|
|
|
|
let icon = ((app) => {switch (app) {
|
|
|
|
case "genius": return "lyrics";
|
2020-06-05 16:15:43 +02:00
|
|
|
case "JQBX": return "addsuggestedsong";
|
2020-05-06 11:55:08 +02:00
|
|
|
case "bookmark": return "tag";
|
|
|
|
case "reddit": return "discover";
|
|
|
|
case "made-for-you": return "user";
|
|
|
|
case "recently-played": return "time";
|
|
|
|
case "collection-songs": return "collection";
|
|
|
|
case "collection:albums": return "album";
|
|
|
|
case "collection:artists": return "artist";
|
|
|
|
case "collection:podcasts": return "podcasts";
|
2020-05-09 17:09:15 +02:00
|
|
|
case "playlist:local-files": return "localfile";
|
|
|
|
case "stations": return "stations";
|
2020-08-08 21:09:25 +02:00
|
|
|
/**
|
|
|
|
* Uncomment 3 lines below if you're using old version of Spotify that
|
|
|
|
* does not have Home/Browse/Radio app icons by default.
|
|
|
|
*/
|
|
|
|
//case "home": return "home";
|
|
|
|
//case "browse": return "browse";
|
|
|
|
//case "radio": return "radio";
|
2020-05-06 11:55:08 +02:00
|
|
|
}})(item.href.replace("spotify:app:", ""));
|
2020-08-05 20:24:44 +02:00
|
|
|
|
2020-07-05 13:28:41 +02:00
|
|
|
replaceTextWithIcon(item.firstChild, icon);
|
2020-05-06 11:55:08 +02:00
|
|
|
});
|
2020-07-05 13:28:41 +02:00
|
|
|
|
|
|
|
waitForElement([`[href="spotify:app:recently-played"]`], ([query]) => {
|
|
|
|
replaceTextWithIcon(query.firstChild, "time");
|
|
|
|
});
|
2020-05-06 11:55:08 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
waitForElement(["#search-input"], (queries) => {
|
|
|
|
queries[0].setAttribute("placeholder", "");
|
|
|
|
});
|
|
|
|
|
|
|
|
waitForElement(["#main-container"], (queries) => {
|
|
|
|
const shadow = document.createElement("div");
|
2020-05-10 15:35:55 +02:00
|
|
|
shadow.id = "dribbblish-back-shadow";
|
2020-05-06 11:55:08 +02:00
|
|
|
queries[0].prepend(shadow);
|
|
|
|
});
|
|
|
|
|
|
|
|
waitForElement([".LeftSidebar"], (queries) => {
|
|
|
|
const fade = document.createElement("div");
|
2020-05-10 15:35:55 +02:00
|
|
|
fade.id = "dribbblish-sidebar-fade-in";
|
2020-05-06 11:55:08 +02:00
|
|
|
queries[0].append(fade);
|
|
|
|
});
|
2021-04-22 03:23:29 +02:00
|
|
|
|
|
|
|
(function Dribbblish() {
|
|
|
|
if (!Spicetify.Player.origin) {
|
|
|
|
setTimeout(Dribbblish, 300);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const progBar = Spicetify.Player.origin.progressbar;
|
|
|
|
|
|
|
|
// Remove default elapsed element update since we already hide it
|
|
|
|
progBar._listenerMap["progress"].pop();
|
|
|
|
|
|
|
|
const tooltip = document.createElement("div");
|
|
|
|
tooltip.className = "handle prog-tooltip";
|
|
|
|
|
|
|
|
progBar._innerElement.append(tooltip);
|
|
|
|
|
|
|
|
Spicetify.Player.origin.progressbar.addListener("progress", (e) => {
|
|
|
|
const curWidth = progBar._innerElement.offsetWidth;
|
|
|
|
const maxWidth = progBar._container.offsetWidth;
|
|
|
|
const ttWidth = tooltip.offsetWidth / 2;
|
|
|
|
if (curWidth < ttWidth) {
|
|
|
|
tooltip.style.right = String(-ttWidth * 2 + curWidth) + "px";
|
|
|
|
} else if (curWidth > maxWidth - ttWidth) {
|
|
|
|
tooltip.style.right = String(curWidth - maxWidth) + "px";
|
|
|
|
} else {
|
|
|
|
tooltip.style.right = String(-ttWidth) + "px";
|
|
|
|
}
|
|
|
|
tooltip.innerText = Spicetify.Player.formatTime(e.value) + " / " +
|
|
|
|
Spicetify.Player.formatTime(Spicetify.Player.getDuration());
|
|
|
|
});
|
|
|
|
})();
|