From 924534ca33cea95cce3214c9896d04381e2acfa4 Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 11 Dec 2023 16:15:42 -0500 Subject: first commit --- CustomApps/legacyLibrary/index.js | 45 +++++++++++++++++++++++ CustomApps/legacyLibrary/legacylibrary.js | 24 +++++++++++++ CustomApps/legacyLibrary/loadcss.js | 59 +++++++++++++++++++++++++++++++ CustomApps/legacyLibrary/manifest.json | 6 ++++ 4 files changed, 134 insertions(+) create mode 100644 CustomApps/legacyLibrary/index.js create mode 100644 CustomApps/legacyLibrary/legacylibrary.js create mode 100644 CustomApps/legacyLibrary/loadcss.js create mode 100644 CustomApps/legacyLibrary/manifest.json (limited to 'CustomApps') 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',` + ` + ); + 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": "", + "active-icon": "", + "subfiles_extension": ["legacylibrary.js","loadcss.js"] +} \ No newline at end of file -- cgit v1.2.3