diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2023-12-11 16:15:42 -0500 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2023-12-11 16:15:42 -0500 |
commit | 924534ca33cea95cce3214c9896d04381e2acfa4 (patch) | |
tree | 17bdc4e4f3fe84b60c22b3de7b408a66cc13ce4b /CustomApps | |
download | legacyLibrary-924534ca33cea95cce3214c9896d04381e2acfa4.tar.gz legacyLibrary-924534ca33cea95cce3214c9896d04381e2acfa4.tar.bz2 legacyLibrary-924534ca33cea95cce3214c9896d04381e2acfa4.zip |
first commit
Diffstat (limited to 'CustomApps')
-rw-r--r-- | CustomApps/legacyLibrary/index.js | 45 | ||||
-rw-r--r-- | CustomApps/legacyLibrary/legacylibrary.js | 24 | ||||
-rw-r--r-- | CustomApps/legacyLibrary/loadcss.js | 59 | ||||
-rw-r--r-- | CustomApps/legacyLibrary/manifest.json | 6 |
4 files changed, 134 insertions, 0 deletions
diff --git a/CustomApps/legacyLibrary/index.js b/CustomApps/legacyLibrary/index.js new file mode 100644 index 0000000..b435ddc --- /dev/null +++ b/CustomApps/legacyLibrary/index.js @@ -0,0 +1,45 @@ +// this part was mostly copied from an example + +// Grab any variables you need +const react = Spicetify.React; +const reactDOM = Spicetify.ReactDOM; +const { + URI, + React: { useState, useEffect, useCallback }, + Platform: { History }, +} = Spicetify; + +// this is called when the page is open +function render() { + Spicetify.Platform.History.replace("collection"); + // element.classList.add("main-yourLibraryX-navLinkActive", "active"); + return react.createElement(Grid, { title: "Open in the main view" }); +} + +//builds components of the page +class Grid extends react.Component { + constructor(props) { + super(props); + Object.assign(this, props); + this.state = { + foo: "bar", //dont know what these do but its working so ill leave them be + data: "etc" + }; + } + + render() { + return react.createElement("section", { + className: "betterLibSection", + }, + react.createElement("div",{ + className: "betterLibBox" + }, + react.createElement("div", { + className: "betterLibText", + }, + react.createElement("h4", null, this.props.title), + ), + ) + ); + } +} diff --git a/CustomApps/legacyLibrary/legacylibrary.js b/CustomApps/legacyLibrary/legacylibrary.js new file mode 100644 index 0000000..5a10093 --- /dev/null +++ b/CustomApps/legacyLibrary/legacylibrary.js @@ -0,0 +1,24 @@ +function startLegacyLibListener() { + setTimeout(function() { + var libraryButton = document.querySelector('[data-id="/legacyLibrary"]').children[0]; + var classes = ["main-yourLibraryX-navLinkActive", "active"]; + Spicetify.Platform.History.listen((location) => { + console.log("called"); + if (location.pathname.includes("/collection") && location.pathname != "/collection/tracks") + { + if (!libraryButton.classList.contains(...classes)) + { + console.log("tried to add"); + libraryButton.classList.add(...classes); + } + } + else + { + if (libraryButton.classList.contains(...classes)) + { + libraryButton.classList.remove(...classes); + } + } + }); + }, 1000); +} diff --git a/CustomApps/legacyLibrary/loadcss.js b/CustomApps/legacyLibrary/loadcss.js new file mode 100644 index 0000000..a231694 --- /dev/null +++ b/CustomApps/legacyLibrary/loadcss.js @@ -0,0 +1,59 @@ +(function loadcss() { + console.log("got here"); + document.getElementsByTagName('head')[0].insertAdjacentHTML( + 'beforeend',` + <style> + /* hide placeholder text */ + .betterLibText { + display: none; + } + + /* hides the library header when in the sidebar*/ + .main-yourLibraryX-library .main-yourLibraryX-header { + display: none; + } + + /* shows the library header if the user is in a folder*/ + .main-yourLibraryX-library .main-yourLibraryX-header:has(.WYU7SXdABSulyirnmIYb) { + display: flex; + } + + /* hides collapse button (library icon)*/ + span.IconWrapper__Wrapper-sc-16usrgb-0.Wrapper-medium-leading { + display: none; + } + + /* hides collapse button (library icon) in folder*/ + /* button.Button-sc-1dqy6lx-0.Button-medium-medium-buttonTertiary-iconOnly-condensed-useBrowserDefaultFocusStyle.main-yourLibraryX-collapseButtonWrapper.main-yourLibraryX-button.main-useDropTarget-base.main-useDropTarget-track.main-useDropTarget-local.main-useDropTarget-album.main-useDropTarget-episode.main-useDropTarget-playlistV2.main-useDropTarget-folder, */ + button.Button-sc-1dqy6lx-0.Button-medium-medium-buttonTertiary-iconOnly-condensed-useBrowserDefaultFocusStyle.main-yourLibraryX-collapseButtonWrapper.main-yourLibraryX-button.main-useDropTarget-base { + display: none; + } + + /* hides expand/reduce button (<- ->)(and also add(+) and more(...))*/ + button.Button-sc-1dqy6lx-0.Button-small-small-buttonTertiary-iconOnly-useBrowserDefaultFocusStyle.main-yourLibraryX-button.main-yourLibraryX-iconOnly.main-useDropTarget-base { + display: none; + } + + /* unhides add(+) and more(...)*/ + span button.Button-sc-1dqy6lx-0.Button-small-small-buttonTertiary-iconOnly-useBrowserDefaultFocusStyle.main-yourLibraryX-button.main-yourLibraryX-iconOnly.main-useDropTarget-base { + display: inherit; + } + + /* add more top padding to the sidebar */ + .main-yourLibraryX-library { + padding-top: 5px; + } + + /* fixes icons on collapsed betterlibrary */ + span.Type__TypeElement-sc-goli3j-0.TypeElement-balladBold-type { + display: var(--betterlib-fix-collaped-view,inherit); + } + + /* for future setting */ + .main-yourLibraryX-entryPoints.main-yourLibraryX-library { + display: var(--betterlib-hide-sidebar-library,inherit); + } + </style>` + ); + startLegacyLibListener(); +})();
\ No newline at end of file diff --git a/CustomApps/legacyLibrary/manifest.json b/CustomApps/legacyLibrary/manifest.json new file mode 100644 index 0000000..8c67ce3 --- /dev/null +++ b/CustomApps/legacyLibrary/manifest.json @@ -0,0 +1,6 @@ +{ + "name": "Your Library", + "icon": "<svg role=\"img\" height=\"24\" width=\"24\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" data-encore-id=\"icon\" class=\"Svg-sc-ytk21e-0 Svg-img-24-icon\"><path d=\"M14.5 2.134a1 1 0 0 1 1 0l6 3.464a1 1 0 0 1 .5.866V21a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1V3a1 1 0 0 1 .5-.866zM16 4.732V20h4V7.041l-4-2.309zM3 22a1 1 0 0 1-1-1V3a1 1 0 0 1 2 0v18a1 1 0 0 1-1 1zm6 0a1 1 0 0 1-1-1V3a1 1 0 0 1 2 0v18a1 1 0 0 1-1 1z\"></path></svg>", + "active-icon": "<svg role=\"img\" height=\"24\" width=\"24\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" data-encore-id=\"icon\" class=\"Svg-sc-ytk21e-0 Svg-img-24-icon\"><path d=\"M3 22a1 1 0 0 1-1-1V3a1 1 0 0 1 2 0v18a1 1 0 0 1-1 1zM15.5 2.134A1 1 0 0 0 14 3v18a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V6.464a1 1 0 0 0-.5-.866l-6-3.464zM9 2a1 1 0 0 0-1 1v18a1 1 0 1 0 2 0V3a1 1 0 0 0-1-1z\"></path></svg>", + "subfiles_extension": ["legacylibrary.js","loadcss.js"] +}
\ No newline at end of file |