mirror of
https://github.com/morpheusthewhite/spicetify-themes.git
synced 2024-11-22 19:02:45 +01:00
Merge pull request #226 from JulienMaille/patch-1
add: ability to hide sidebar item (cherry picked)
This commit is contained in:
commit
38c543b940
@ -1,6 +1,37 @@
|
|||||||
// Hide popover message
|
// Hide popover message
|
||||||
document.getElementById("popover-container").style.height = 0;
|
document.getElementById("popover-container").style.height = 0;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
function waitForElement(els, func, timeout = 100) {
|
function waitForElement(els, func, timeout = 100) {
|
||||||
const queries = els.map(el => document.querySelector(el));
|
const queries = els.map(el => document.querySelector(el));
|
||||||
if (queries.every(a => a)) {
|
if (queries.every(a => a)) {
|
||||||
@ -82,11 +113,23 @@ waitForElement([".LeftSidebar", ".LeftSidebar__section--rootlist .SidebarList__l
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function replaceTextWithIcon(el, iconName) {
|
function replaceTextWithIcon(el, iconName) {
|
||||||
|
const href = el.parentNode.href;
|
||||||
|
if (appHiddenList.indexOf(href) !== -1) {
|
||||||
|
let parent = el;
|
||||||
|
while (parent.tagName !== "LI") {
|
||||||
|
parent = parent.parentNode;
|
||||||
|
}
|
||||||
|
parent.remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (iconName) {
|
if (iconName) {
|
||||||
el.classList.add(`spoticon-${iconName}-24`);
|
el.classList.add(`spoticon-${iconName}-24`);
|
||||||
}
|
}
|
||||||
|
|
||||||
el.parentNode.setAttribute("data-tooltip", el.innerText);
|
el.parentNode.setAttribute("data-tooltip", el.innerText);
|
||||||
|
el.parentNode.setAttribute("data-contextmenu", "");
|
||||||
|
el.parentNode.setAttribute("data-uri", "spotify:special:sidebarapp:" + href);
|
||||||
el.innerText = "";
|
el.innerText = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user