From bd3bb54151b3ae64557f413d11dcb069c4d129f3 Mon Sep 17 00:00:00 2001 From: Thomas Fitzpatrick <22730962+ohitstom@users.noreply.github.com> Date: Mon, 4 Mar 2024 02:42:21 +0000 Subject: [PATCH] Update spicetifyWrapper.js --- jsHelper/spicetifyWrapper.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/jsHelper/spicetifyWrapper.js b/jsHelper/spicetifyWrapper.js index 100a73d99a..009bbbe3be 100644 --- a/jsHelper/spicetifyWrapper.js +++ b/jsHelper/spicetifyWrapper.js @@ -1993,7 +1993,8 @@ Spicetify.Topbar = (() => { class Button { constructor(label, icon, onClick, disabled = false, isRight = false) { - this.element = document.createElement("button"); + this.element = document.createElement("div"); + this.button = document.createElement("button"); this.icon = icon; this.onClick = onClick; this.disabled = disabled; @@ -2003,10 +2004,11 @@ Spicetify.Topbar = (() => { }); this.label = label; + this.element.appendChild(this.button); if (isRight) { - this.element.classList.add("encore-over-media-set", "main-topBar-buddyFeed"); + this.button.classList.add("encore-over-media-set", "main-topBar-buddyFeed"); rightButtonsStash.add(this.element); - rightContainer?.after(this.element); + rightContainer?.prepend(this.element); } else { this.element.classList.add("main-topBar-button"); leftButtonsStash.add(this.element); @@ -2018,7 +2020,8 @@ Spicetify.Topbar = (() => { } set label(text) { this._label = text; - if (!this.tippy) this.element.setAttribute("title", text); + this.button.setAttribute("aria-label", text); + if (!this.tippy) this.button.setAttribute("title", text); else this.tippy.setContent(text); } get icon() { @@ -2030,22 +2033,22 @@ Spicetify.Topbar = (() => { newInput = `${Spicetify.SVGIcons[newInput]}`; } this._icon = newInput; - this.element.innerHTML = newInput; + this.button.innerHTML = newInput; } get onClick() { return this._onClick; } set onClick(func) { this._onClick = func; - this.element.onclick = () => this._onClick(this); + this.button.onclick = () => this._onClick(this); } get disabled() { return this._disabled; } set disabled(bool) { this._disabled = bool; - this.element.disabled = bool; - this.element.classList.toggle("disabled", bool); + this.button.disabled = bool; + this.button.classList.toggle("disabled", bool); } } @@ -2063,7 +2066,7 @@ Spicetify.Topbar = (() => { for (const button of rightButtonsStash) { if (button.parentNode) button.parentNode.removeChild(button); } - rightContainer.after(...rightButtonsStash); + rightContainer.prepend(...rightButtonsStash); } waitForTopbarMounted();