From 04c96a7081af7a7811a8ff3f5edfdf5e3c56d5dc Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Sat, 12 Oct 2024 16:14:24 +0200 Subject: [PATCH] IMP: moon button insertion --- default-dynamic.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/default-dynamic.js b/default-dynamic.js index db3e2ed..25d3d38 100644 --- a/default-dynamic.js +++ b/default-dynamic.js @@ -142,21 +142,27 @@ window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) toggleDark(e.matches); }); -waitForElement([".main-topBar-topbarContentRight"], (queries) => { +waitForElement([".main-actionButtons"], (queries) => { // Add activator on top bar - const div = document.createElement("div"); - div.id = "main-topBar-moon-div"; - queries[0].insertBefore(div, queries[0].querySelector(".main-actionButtons")); + const buttonContainer = queries[0]; const button = document.createElement("button"); + Array.from(buttonContainer.firstChild.attributes).forEach((attr) => { + button.setAttribute(attr.name, attr.value); + }); button.id = "main-topBar-moon-button"; - button.classList.add("main-topBar-buddyFeed", "Button-small-small-buttonTertiary-condensedAll-useBrowserDefaultFocusStyle"); - button.setAttribute("title", "Light/Dark"); + button.className = buttonContainer.firstChild.className; button.onclick = () => { toggleDark(); }; button.innerHTML = ``; - div.append(button); + + const tooltip = Spicetify.Tippy(button, { + ...Spicetify.TippyProps, + content: "Light/Dark" + }); + + buttonContainer.insertBefore(button, buttonContainer.firstChild); }); function updateColors(textColHex) {