diff --git a/app.css b/app.css index 708de35..27818e5 100644 --- a/app.css +++ b/app.css @@ -8,6 +8,25 @@ svg { overflow: visible; } +/*------------------- +NAV STYLES +-------------------*/ +.spotify__container--is-desktop.spotify__os--is-windows .control-nav .main-topBar-container, +.spotify__container--is-desktop.spotify__os--is-windows .global-nav .Root__globalNav { + --top-bar-padding-start: calc(64px / var(--zoom)); + --top-bar-padding-end: calc(144px / var(--zoom)); +} + +.spotify__container--is-desktop.spotify__os--is-macos .control-nav .main-topBar-container, +.spotify__container--is-desktop.spotify__os--is-macos .global-nav .Root__globalNav { + --top-bar-padding-start: calc(80px / var(--zoom)); +} + +.Root__globalNav, +.control-nav .main-topBar-container { + padding-inline: var(--top-bar-padding-start, var(--panel-gap, 0.5rem)) var(--top-bar-padding-end, var(--panel-gap, 0.5rem)); +} + /*------------------- ALBUM ART BACKGROUND -------------------*/ @@ -21,12 +40,8 @@ ALBUM ART BACKGROUND transition: background-image var(--fade-time) ease !important; position: fixed; display: block; - top: 0; - left: 0; - right: 0; - bottom: 0; - filter: blur(var(--blur)) contrast(var(--cont)) saturate(var(--satu)) - brightness(var(--bright)); + inset: 0; + filter: blur(var(--blur)) contrast(var(--cont)) saturate(var(--satu)) brightness(var(--bright)); pointer-events: none; backface-visibility: hidden; will-change: transform; @@ -39,15 +54,29 @@ ALBUM ART BACKGROUND TRANSPARENT WINDOW CONTROLS --------------------------*/ -html:not(.spotify__container--is-desktop.fullscreen) - body.windows:not(.video-full-window)::after { +.Root__top-container { + padding-top: max(var(--topbar-height, 68px) / var(--zoom, 1), 8px); +} + +html:not(.spotify__container--is-desktop.fullscreen) body.windows:not(.video-full-window)::after { content: ""; position: absolute; right: 0; z-index: 999; + -webkit-backdrop-filter: brightness(2.12); backdrop-filter: brightness(2.12); - width: var(--control-width); - height: var(--control-height); + width: calc(135px / var(--zoom, 1)); + height: calc(var(--topbar-height, 40px) / var(--zoom, 1)); +} + +html:not(.spotify__container--is-desktop.fullscreen) body.global-nav.windows:not(.video-full-window)::after { + --topbar-height: 64px; +} + +html:not(.spotify__container--is-desktop.fullscreen) body.global-nav-centered.windows:not(.video-full-window)::after { + height: min(32px / var(--zoom, 1), + var(--topbar-height, 64px) / var(--zoom, 1)); + top: calc((var(--topbar-height, 64px) / var(--zoom, 1) - min(32px / var(--zoom, 1), var(--topbar-height, 64px))) / 2); } /*------------ @@ -60,15 +89,18 @@ NAVIGATION BAR .Root__nav-bar [fade="top"] { -webkit-mask-image: linear-gradient(transparent 0%, rgba(0, 0, 0, 1) 20%); + mask-image: linear-gradient(transparent 0%, rgba(0, 0, 0, 1) 20%); } .Root__nav-bar [fade="full"] { - -webkit-mask-image: linear-gradient( - transparent 0%, - rgba(0, 0, 0, 1) 12%, - rgba(0, 0, 0, 1) 92%, - transparent 100% - ); + -webkit-mask-image: linear-gradient(transparent 0%, + rgba(0, 0, 0, 1) 12%, + rgba(0, 0, 0, 1) 92%, + transparent 100%); + mask-image: linear-gradient(transparent 0%, + rgba(0, 0, 0, 1) 12%, + rgba(0, 0, 0, 1) 92%, + transparent 100%); } .main-yourLibraryX-entryPoints { @@ -159,7 +191,7 @@ NOW PLAYING BAR transform: unset !important; } -.main-nowPlayingWidget-coverExpanded > .main-coverSlotCollapsed-container { +.main-nowPlayingWidget-coverExpanded>.main-coverSlotCollapsed-container { transform: translateX(-8px) scale(1) !important; } @@ -174,12 +206,8 @@ NOW PLAYING BAR height: 11px; } -.playback-progressbar-isInteractive - .DuvrswZugGajIFNXObAr - .x-progressBar-fillColor, -.playback-progressbar-isInteractive - .DuvrswZugGajIFNXObAr - .progress-bar__slider { +.playback-progressbar-isInteractive .DuvrswZugGajIFNXObAr .x-progressBar-fillColor, +.playback-progressbar-isInteractive .DuvrswZugGajIFNXObAr .progress-bar__slider { transition: none; } @@ -214,7 +242,7 @@ SIDEBAR } /* tentative fix for sidebar box shadow */ -.main-nowPlayingView-nowPlayingWidget > div > div:nth-child(1) > div { +.main-nowPlayingView-nowPlayingWidget>div>div:nth-child(1)>div { box-shadow: none !important; } @@ -273,10 +301,10 @@ SIDEBAR } .main-nowPlayingView-aboutArtistV2ImageContainer.main-nowPlayingView-aboutArtistV2Image { - -webkit-mask-image: linear-gradient( - rgba(0, 0, 0, 0.95) 75%, - transparent 100% - ) !important; + -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 0.95) 75%, + transparent 100%) !important; + mask-image: linear-gradient(rgba(0, 0, 0, 0.95) 75%, + transparent 100%) !important; } .main-nowPlayingView-aboutArtistV2Button { @@ -304,10 +332,8 @@ WHAT'S NEW --background-highlight: var(--backdrop); } -.main-whatsNewFeed-listRow:hover - + .main-whatsNewFeed-listRow - > .main-whatsNewFeed-divider, -.main-whatsNewFeed-listRow:hover > .main-whatsNewFeed-divider, +.main-whatsNewFeed-listRow:hover+.main-whatsNewFeed-listRow>.main-whatsNewFeed-divider, +.main-whatsNewFeed-listRow:hover>.main-whatsNewFeed-divider, .main-whatsNewFeed-listRow:only-child .main-whatsNewFeed-divider { visibility: unset; } @@ -320,12 +346,12 @@ WHAT'S NEW padding: 2px 16px 16px 16px; } -.main-whatsNewFeed-content > p { +.main-whatsNewFeed-content>p { display: none; } .main-whatsNewFeed-list:last-child, -.main-buddyFeed-content > div:nth-child(3) > ol:last-child { +.main-buddyFeed-content>div:nth-child(3)>ol:last-child { padding-bottom: 8px; } @@ -360,7 +386,7 @@ PLAYLIST VIEW background-color: var(--backdrop) !important; } -[dir="ltr"] .main-actionBar-ActionBarRow > :not(:last-child) { +[dir="ltr"] .main-actionBar-ActionBarRow> :not(:last-child) { margin-right: 24px; } @@ -384,24 +410,24 @@ PLAYLIST VIEW background: none !important; } -.main-rootlist-wrapper > div[role="presentation"] > div[aria-selected="true"] { +.main-rootlist-wrapper>div[role="presentation"]>div[aria-selected="true"] { background-color: hsla(0, 0%, 100%, 0.1); border-radius: 8px; } -.main-trackList-rowSectionStart > img { +.main-trackList-rowSectionStart>img { box-shadow: 0px 2px 10px 2px rgb(0 0 0 / 15%); } -.main-trackList-rowMainContent > div { +.main-trackList-rowMainContent>div { text-shadow: 0 0 10px rgb(0 0 0 / 40%); } -.main-trackList-rowMainContent > span, -.main-trackList-rowSectionVariable > span, +.main-trackList-rowMainContent>span, +.main-trackList-rowSectionVariable>span, .main-trackList-rowDuration, .main-trackList-rowPlayCount, -.main-trackList-rowMarker > span { +.main-trackList-rowMarker>span { text-shadow: 0 0 10px rgb(0 0 0 / 20%); } @@ -456,7 +482,7 @@ PLAYLIST VIEW border-radius: var(--button-border); } -.main-nowPlayingView-nowPlayingWidget > div > div:nth-child(1) > div { +.main-nowPlayingView-nowPlayingWidget>div>div:nth-child(1)>div { box-shadow: 0px 4px 10px 3px rgb(0 0 0 / 12%); } @@ -488,19 +514,23 @@ TOP BAR [fade="bottom"] { -webkit-mask-image: linear-gradient(rgba(0, 0, 0, 1) 95%, transparent 100%); + mask-image: linear-gradient(rgba(0, 0, 0, 1) 95%, transparent 100%); } [fade="top"] { -webkit-mask-image: linear-gradient(transparent 9%, rgba(0, 0, 0, 1) 15%); + mask-image: linear-gradient(transparent 9%, rgba(0, 0, 0, 1) 15%); } [fade="full"] { - -webkit-mask-image: linear-gradient( - transparent 9%, - rgba(0, 0, 0, 1) 15%, - rgba(0, 0, 0, 1) 95%, - transparent 100% - ); + -webkit-mask-image: linear-gradient(transparent 9%, + rgba(0, 0, 0, 1) 15%, + rgba(0, 0, 0, 1) 95%, + transparent 100%); + mask-image: linear-gradient(transparent 9%, + rgba(0, 0, 0, 1) 15%, + rgba(0, 0, 0, 1) 95%, + transparent 100%); } .main-topBar-background { @@ -539,7 +569,7 @@ TOP BAR transition: 0.2s ease; } -.SFgYidQmrqrFEVh65Zrg > figure > div > img { +.SFgYidQmrqrFEVh65Zrg>figure>div>img { border-radius: 6px !important; } @@ -569,12 +599,13 @@ PLAY BUTTONS .ix_8kg3iUb9VS5SmTnBY span.ButtonInner-sc-14ud5tc-0.encore-bright-accent-set, .view-homeShortcutsGrid-playButton>span>svg -/* Home Shortcut Grid Play Button */ { +/* Home Shortcut Grid Play Button */ + { background: none !important; color: var(--spice-text) !important; } -.main-playButton-PlayButton > button > span { +.main-playButton-PlayButton>button>span { color: var(--spice-text) !important; background: transparent; border-radius: var(--button-border); @@ -582,27 +613,27 @@ PLAY BUTTONS transition: all 0.2s ease; } -.main-playButton-PlayButton > button > span { +.main-playButton-PlayButton>button>span { background: none !important; transform: scale(1.1) !important; } .view-homeShortcutsGrid-playButton { -webkit-box-shadow: none !important; + box-shadow: none !important; background-color: transparent; } -.Button-small-buttonPrimary-useBrowserDefaultFocusStyle:hover - .ButtonInner-sc-14ud5tc-0 { +.Button-small-buttonPrimary-useBrowserDefaultFocusStyle:hover .ButtonInner-sc-14ud5tc-0 { background: none !important; } -.main-card-PlayButtonContainer > div > button > span > span > svg, -.main-heroCard-PlayButtonContainer > div > button > span > span > svg { +.main-card-PlayButtonContainer>div>button>span>span>svg, +.main-heroCard-PlayButtonContainer>div>button>span>span>svg { filter: drop-shadow(-1px 1px 6px rgba(0, 0, 0, 1)) !important; } -.main-playButton-PlayButton > button > span:hover { +.main-playButton-PlayButton>button>span:hover { transform: scale(1.2) !important; } @@ -710,7 +741,7 @@ SEARCH BAR margin-top: 3px; } -.search-searchCategory-categoryGridItem > button > span { +.search-searchCategory-categoryGridItem>button>span { border-radius: var(--button-border); font-weight: 700 !important; } @@ -730,8 +761,7 @@ SEARCH BAR box-shadow: none; } -.search-searchCategory-categoryGridItembutton[aria-checked="false"] - > button:hover { +.search-searchCategory-categoryGridItembutton[aria-checked="false"]>button:hover { background-color: rgba(0, 0, 0, 0.2) !important; color: var(--spicet-text); } @@ -743,7 +773,7 @@ SEARCH BAR border-radius: var(--button-border) !important; } -.main-card-draggable:not(:hover) > .sHDdcNIw9AQLbLrpdcqO { +.main-card-draggable:not(:hover)>.sHDdcNIw9AQLbLrpdcqO { opacity: 0 !important; } @@ -840,16 +870,18 @@ MISCELLANEOUS } .main-buddyFeed-scrollBarContainer [data-overlayscrollbars-viewport] { - -webkit-mask-image: linear-gradient( - transparent 1%, - rgba(0, 0, 0, 1) 5%, - rgba(0, 0, 0, 1) 96%, - transparent 100% - ); -} - -.main-playlistEditDetailsModal-save > button > span, -.main-duplicateTrackModal-buttonContainer > button > span { + -webkit-mask-image: linear-gradient(transparent 1%, + rgba(0, 0, 0, 1) 5%, + rgba(0, 0, 0, 1) 96%, + transparent 100%); + mask-image: linear-gradient(transparent 1%, + rgba(0, 0, 0, 1) 5%, + rgba(0, 0, 0, 1) 96%, + transparent 100%); +} + +.main-playlistEditDetailsModal-save>button>span, +.main-duplicateTrackModal-buttonContainer>button>span { margin-left: auto; position: relative; color: #fff; @@ -868,8 +900,8 @@ MISCELLANEOUS padding-block: 12px; } -.main-playlistEditDetailsModal-save > button > span:hover, -.main-duplicateTrackModal-buttonContainer > button > span:hover { +.main-playlistEditDetailsModal-save>button>span:hover, +.main-duplicateTrackModal-buttonContainer>button>span:hover { background-color: #23c483 !important; box-shadow: 0px 0px 15px 5px rgba(46, 229, 157, 0.4); transform: scale(1) !important; @@ -881,6 +913,7 @@ MISCELLANEOUS .main-popper-container { background-color: rgba(0, 0, 0, 0.45); + -webkit-backdrop-filter: blur(25px) !important; backdrop-filter: blur(25px) !important; } @@ -900,12 +933,14 @@ MISCELLANEOUS } .LyricsScrollContainer { - -webkit-mask-image: linear-gradient( - transparent 5%, - rgba(0, 0, 0, 1) 30%, - rgba(0, 0, 0, 1) 85%, - transparent 100% - ); + -webkit-mask-image: linear-gradient(transparent 5%, + rgba(0, 0, 0, 1) 30%, + rgba(0, 0, 0, 1) 85%, + transparent 100%); + mask-image: linear-gradient(transparent 5%, + rgba(0, 0, 0, 1) 30%, + rgba(0, 0, 0, 1) 85%, + transparent 100%); } .app-module__StatsButton___gLukm_nameDthatDtune { @@ -927,7 +962,7 @@ TEXT SHADOWS .playlist-playlist-playlistDescription, .main-entityHeader-detailsText, .main-entityHeader-title, -.artist-artistVerifiedBadge-wrapper > span, +.artist-artistVerifiedBadge-wrapper>span, .main-buddyFeed-link, .main-trackInfo-name, .main-trackInfo-contentWrapper, @@ -935,7 +970,7 @@ TEXT SHADOWS .main-yourLibraryX-listRowSubtitle, .ListRowTitle__LineClamp-sc-1xe2if1-0, .main-yourLibraryX-header .main-yourLibraryX-collapseButtonWrapper, -.main-yourLibraryX-navItem > a > span, +.main-yourLibraryX-navItem>a>span, .playback-bar__progress-time-elapsed, .cvTLPmjt6T7M85EKcB8w { text-shadow: -1px 3px 20px rgb(0 0 0 / 20%); @@ -954,8 +989,7 @@ ALBUM VIEW background: none; } -.nav-ylx - .artist-artistDiscography-topBar.artist-artistDiscography-topBarScrolled, +.nav-ylx .artist-artistDiscography-topBar.artist-artistDiscography-topBarScrolled, .artist-artistDiscography-topBar.artist-artistDiscography-topBarScrolled { background: none; border-bottom: none; @@ -970,21 +1004,20 @@ ALBUM VIEW } .ButtonInner-sm-iconOnly, -.Button-sm-buttonPrimary-useBrowserDefaultFocusStyle:hover - .ButtonInner-sc-14ud5tc-0 { +.Button-sm-buttonPrimary-useBrowserDefaultFocusStyle:hover .ButtonInner-sc-14ud5tc-0 { background: none; color: var(--background-base, #ffffff); scale: 1.2; } -.ix_8kg3iUb9VS5SmTnBY > button > span { +.ix_8kg3iUb9VS5SmTnBY>button>span { color: var(--spice-text); background: none; scale: 1.2; transition: all 0.2s ease; } -.ix_8kg3iUb9VS5SmTnBY > button > span:hover { +.ix_8kg3iUb9VS5SmTnBY>button>span:hover { color: var(--spice-text); background: none; scale: 1.3; @@ -1004,7 +1037,7 @@ HOME VIEW background: none !important; } -.search-searchCategory-catergoryGrid > div > button > span { +.search-searchCategory-catergoryGrid>div>button>span { border-radius: var(--button-border); } @@ -1040,8 +1073,7 @@ HOME VIEW } .view-homeShortcutsGrid-shortcut:hover .view-homeShortcutsGrid-equaliser, -.view-homeShortcutsGrid-shortcut:hover - .view-homeShortcutsGrid-shortcutNewEpisodeIndicator { +.view-homeShortcutsGrid-shortcut:hover .view-homeShortcutsGrid-shortcutNewEpisodeIndicator { display: none; } @@ -1164,11 +1196,11 @@ SETTINGS background-color: var(--backdrop); } -input:hover:not([disabled], :active) ~ .x-toggle-indicatorWrapper { +input:hover:not([disabled], :active)~.x-toggle-indicatorWrapper { background-color: rgb(255 255 255 / 10%); } -input:hover ~ .x-toggle-indicatorWrapper { +input:hover~.x-toggle-indicatorWrapper { background-color: var(--backdrop); } @@ -1186,10 +1218,10 @@ ARTIST PAGE } .main-entityHeader-background.main-entityHeader-gradient { - -webkit-mask-image: linear-gradient( - rgba(0, 0, 0, var(--artist-fade)) 58%, - transparent 100% - ); + -webkit-mask-image: linear-gradient(rgba(0, 0, 0, var(--artist-fade)) 58%, + transparent 100%); + mask-image: linear-gradient(rgba(0, 0, 0, var(--artist-fade)) 58%, + transparent 100%); } .artist-artistOverview-artistOverviewContent { @@ -1213,6 +1245,7 @@ ARTIST PAGE .profile-userEditDetails-container, .artist-artistAbout-modal { background-color: rgba(0, 0, 0, 0.4) !important; + -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); border-radius: 8px; } @@ -1238,12 +1271,12 @@ ARTIST PAGE background: none; } -.SxHlW6byhoJSUJNugaE1 > figure > div > img { +.SxHlW6byhoJSUJNugaE1>figure>div>img { border-radius: 8px; } .mYvNDps8FDVgHSCzpeqC, -.o6lOM3qmit24hWlOBbw0 > img { +.o6lOM3qmit24hWlOBbw0>img { border-radius: 8px !important; } @@ -1311,7 +1344,7 @@ BLOOM LYRICS } /* right sidebar lyrics */ -.main-nowPlayingView-lyricsContent > .lyrics-lyricsContent-lyric { +.main-nowPlayingView-lyricsContent>.lyrics-lyricsContent-lyric { max-width: 90% !important; } @@ -1353,12 +1386,14 @@ BLOOM LYRICS } .Root__lyrics-cinema [data-overlayscrollbars-viewport] { - -webkit-mask-image: linear-gradient( - transparent 0%, - rgba(0, 0, 0, 1) 20%, - rgba(0, 0, 0, 1) 80%, - transparent 100% - ); + -webkit-mask-image: linear-gradient(transparent 0%, + rgba(0, 0, 0, 1) 20%, + rgba(0, 0, 0, 1) 80%, + transparent 100%); + mask-image: linear-gradient(transparent 0%, + rgba(0, 0, 0, 1) 20%, + rgba(0, 0, 0, 1) 80%, + transparent 100%); } .FUYNhisXTCmbzt9IDxnT { @@ -1380,7 +1415,7 @@ SCROLLBAR border-radius: 50px !important; } -.os-theme-spotify > .os-scrollbar-vertical { +.os-theme-spotify>.os-scrollbar-vertical { margin: 12px 2px 12px 0 !important; } @@ -1411,19 +1446,18 @@ SCROLLBAR EXPERIMENTAL FEATURES -------------------*/ -.GenericModal > .main-embedWidgetGenerator-container { +.GenericModal>.main-embedWidgetGenerator-container { background-color: var(--backdrop) !important; + -webkit-backdrop-filter: blur(15px); backdrop-filter: blur(15px); height: 680px; } -.main-embedWidgetGenerator-container - > .main-trackCreditsModal-mainSection::-webkit-scrollbar { +.main-embedWidgetGenerator-container>.main-trackCreditsModal-mainSection::-webkit-scrollbar { width: 4px; } -.main-embedWidgetGenerator-container - > .main-trackCreditsModal-mainSection::-webkit-scrollbar-thumb { +.main-embedWidgetGenerator-container>.main-trackCreditsModal-mainSection::-webkit-scrollbar-thumb { border-radius: 8px; } @@ -1567,6 +1601,7 @@ div#context-menu:before, right: 0; bottom: 0; border-radius: 8px !important; + -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px); } @@ -1623,10 +1658,7 @@ div#context-menu:before, transform: scale(1.1); } -.Root__top-bar - span.ButtonInner-sc-14ud5tc-0.encore-bright-accent-set:hover - .playlist-playlist-playlist - span.ButtonInner-sc-14ud5tc-0.encore-bright-accent-set:hover { +.Root__top-bar span.ButtonInner-sc-14ud5tc-0.encore-bright-accent-set:hover .playlist-playlist-playlist span.ButtonInner-sc-14ud5tc-0.encore-bright-accent-set:hover { transform: scale(1.05); } @@ -1659,7 +1691,7 @@ div[aria-label="Hazy Settings"] .main-trackCreditsModal-mainSection { padding-bottom: 0; } -.main-userWidget-dropDownMenu li.main-contextMenu-menuItem > div { +.main-userWidget-dropDownMenu li.main-contextMenu-menuItem>div { width: 225px; } @@ -1793,7 +1825,7 @@ span.toggle.enabled { font-size: 0.875rem; } -.slider-container > div { +.slider-container>div { color: rgb(255 255 255 / 60%); font-size: 0.8rem; margin-top: 2px; @@ -1831,25 +1863,25 @@ span.toggle.enabled { width: 2px; } -.slider-value > div[id="unit"] { +.slider-value>div[id="unit"] { flex-shrink: 0; } -.slider-value > div[id="unit"], -.slider-value > div[contenteditable="true"] { +.slider-value>div[id="unit"], +.slider-value>div[contenteditable="true"] { color: rgb(255 255 255 / 60%); font-size: 0.8rem; margin-top: 0px; transition: all 0.3s ease !important; } -.slider-value > div[contenteditable="true"]:hover, -.slider-value > div[contenteditable="true"]:focus { +.slider-value>div[contenteditable="true"]:hover, +.slider-value>div[contenteditable="true"]:focus { box-shadow: 0 1px 0 0 rgb(255 255 255 / 60%); } -.slider-value > div[contenteditable="true"]:hover + div[id="unit"], -.slider-value > div[contenteditable="true"]:focus + div[id="unit"] { +.slider-value>div[contenteditable="true"]:hover+div[id="unit"], +.slider-value>div[contenteditable="true"]:focus+div[id="unit"] { box-shadow: 0 1px 0 0 rgb(255 255 255 / 60%); } @@ -1893,4 +1925,4 @@ POPUP MODAL .main-playlistEditDetailsModal-textElement:focus { background-color: rgba(var(--spice-rgb-selected-row), 0.1); -} +} \ No newline at end of file diff --git a/hazy.js b/hazy.js index d9809fa..7975101 100644 --- a/hazy.js +++ b/hazy.js @@ -5,6 +5,7 @@ } console.log("Hazy is running"); + function getAlbumInfo(uri) { return Spicetify.CosmosAsync.get( `https://api.spotify.com/v1/albums/${uri}` @@ -108,7 +109,6 @@ scrollToTop(); } }); - (function sidebar() { // Sidebar settings const item = localStorage.getItem("spicetify-exp-features"); @@ -180,86 +180,41 @@ }); } - function calculateBrowserZoom() { - const viewportWidth = window.innerWidth; - const windowWidth = window.outerWidth; - const zoomLevel = (windowWidth / viewportWidth) * 100; - return zoomLevel; - } - - function calculateInverseBrowserZoom() { - const viewportWidth = window.innerWidth; - const windowWidth = window.outerWidth; - const inverseZoomLevel = viewportWidth / windowWidth; - return inverseZoomLevel; - } - - function calculateScaledPx( - baseWidth, - inverseZoom, - scalingFactorOut = 1, - minWidth = 0, - maxWidth = Number.POSITIVE_INFINITY - ) { - const scaledWidth = baseWidth * (inverseZoom + scalingFactorOut - 1); - return Math.max(minWidth, Math.min(scaledWidth, maxWidth)); - } - - /* Topbar styles */ - const topBarStyleSheet = document.createElement("style"); - async function setTopBarStyles() { - const isGlobalNav = - document.querySelector(".global-nav") || - document.querySelector(".Root__globalNav"); - - const baseHeight = isGlobalNav ? 64 : 42; - const baseWidth = 135; - const constant = 0.912872807; - - const normalZoom = calculateBrowserZoom(); - const inverseZoom = calculateInverseBrowserZoom(); - - const finalControlHeight = Math.round( - (normalZoom ** constant * 100) / 100 - (isGlobalNav ? 3 : 25) - ); - - console.log(finalControlHeight); - - await setMainWindowControlHeight(finalControlHeight); - - const paddingStart = calculateScaledPx(64, inverseZoom, 1); - const paddingEnd = calculateScaledPx(baseWidth, inverseZoom, 1); - - console.log(normalZoom, inverseZoom); + // Window Zoom Variable + function updateZoomVariable() { + let prevOuterWidth = window.outerWidth; + let prevInnerWidth = window.innerWidth; + let prevRatio = window.devicePixelRatio; + + function calculateAndApplyZoom() { + const newOuterWidth = window.outerWidth; + const newInnerWidth = window.innerWidth; + const newRatio = window.devicePixelRatio; + + if ( + prevOuterWidth <= 160 || + prevRatio !== newRatio || + prevOuterWidth !== newOuterWidth || + prevInnerWidth !== newInnerWidth + ) { + const zoomFactor = newOuterWidth / newInnerWidth || 1; + document.documentElement.style.setProperty("--zoom", zoomFactor); + console.debug( + `Zoom Updated: ${newOuterWidth} / ${newInnerWidth} = ${zoomFactor}` + ); - if (isGlobalNav) { - topBarStyleSheet.innerText = ` -.spotify__container--is-desktop.spotify__os--is-windows .Root__globalNav { - padding-inline-end: ${paddingEnd}px !important; - padding-inline-start: ${paddingStart}px !important; -} -`; - } - if ( - Spicetify.Platform.PlatformData.os_name === "windows" || - Spicetify.Platform.PlatformData.os_name === "Windows" - ) { - const transparentControlHeight = baseHeight; - const transparentControlWidth = calculateScaledPx( - baseWidth, - inverseZoom, - 1 - ); - addTransparentControls(transparentControlHeight, transparentControlWidth); + // Update previous values + prevOuterWidth = newOuterWidth; + prevInnerWidth = newInnerWidth; + prevRatio = newRatio; + } } - } - window.addEventListener("resize", () => { - setTopBarStyles(); - }); - setTopBarStyles(); + calculateAndApplyZoom(); + window.addEventListener("resize", calculateAndApplyZoom); + } - document.head.appendChild(topBarStyleSheet); + updateZoomVariable(); function waitForElement(elements, func, timeout = 100) { const queries = elements.map((element) => document.querySelector(element)); @@ -270,6 +225,22 @@ } } + function getAndApplyNav(element) { + const isCenteredGlobalNav = Spicetify.Platform.version >= "1.2.46.462"; + + document.body.classList.add( + `${ + element?.[0]?.classList.contains("Root__globalNav") + ? isCenteredGlobalNav + ? "global-nav-centered" + : "global-nav" + : "control-nav" + }` + ); + } + + waitForElement([".Root__globalNav"], getAndApplyNav, 10000); + Spicetify.Platform.History.listen(updateLyricsPageProperties); waitForElement([".Root__lyrics-cinema"], ([lyricsCinema]) => {