-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export const manageBackgroundZIndex = () => { | ||
type BackgroundContainer = HTMLDivElement | null; | ||
|
||
function applyBackgroundStyles() { | ||
const lyricsCinemaContainer: BackgroundContainer = document.querySelector( | ||
'#lyrics-cinema:has(.lyrics-lyrics-contentContainer)' | ||
); | ||
|
||
if (lyricsCinemaContainer) { | ||
const backgroundContainer: BackgroundContainer = document.querySelector( | ||
'#lucid-main .background-container .background-wrapper div' | ||
); | ||
|
||
if (backgroundContainer) { | ||
backgroundContainer.style.zIndex = | ||
'calc(var(--above-everything-except-now-playing-bar-z-index, 6) - 1)'; | ||
} else { | ||
removeBackgroundZIndex(); | ||
} | ||
} else { | ||
removeBackgroundZIndex(); | ||
} | ||
} | ||
|
||
function removeBackgroundZIndex() { | ||
const backgroundContainer: BackgroundContainer = document.querySelector( | ||
'#lucid-main .background-container .background-wrapper div' | ||
); | ||
|
||
if (backgroundContainer) { | ||
backgroundContainer.style.zIndex = ''; | ||
} | ||
} | ||
|
||
const observer = new MutationObserver((mutations) => { | ||
for (const mutation of mutations) { | ||
if ( | ||
mutation.target instanceof HTMLElement && | ||
mutation.target.id === 'lyrics-cinema' | ||
) { | ||
applyBackgroundStyles(); | ||
} else { | ||
if ( | ||
mutation.target instanceof HTMLElement && | ||
mutation.target.classList.contains('lyrics-lyrics-contentContainer') | ||
) { | ||
applyBackgroundStyles(); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
const config = { childList: true, attributes: true, subtree: true }; | ||
|
||
observer.observe(document.body, config); | ||
|
||
applyBackgroundStyles(); | ||
}; |
Oops, something went wrong.