static lyrics refactoring

This commit is contained in:
amd64fox
2024-09-13 22:48:14 +03:00
parent 2f14e0dab6
commit 8e69ee9f07
3 changed files with 68 additions and 171 deletions

View File

@@ -1,7 +1,9 @@
@import url('colors.css'); @import url('colors.css');
/* mini lyrics */ /* mini lyrics */
.I2WIloMMjsBeMaIS8H3v, .I2WIloMMjsBeMaIS8H3v,
.McI3hD7aCfpq015LJa6X { .McI3hD7aCfpq015LJa6X,
.gpDSOimnzH4zTJmE7UR5 {
--lyrics-color-active: var(--current) !important; --lyrics-color-active: var(--current) !important;
--lyrics-color-inactive: var(--next) !important; --lyrics-color-inactive: var(--next) !important;
--lyrics-color-passed: var(--past) !important; --lyrics-color-passed: var(--past) !important;
@@ -11,7 +13,9 @@
/* musixmatch */ /* musixmatch */
p.encore-text.encore-text-body-small, p.encore-text.encore-text-body-small,
p.Type__TypeElement-sc-goli3j-0.ieTwfQ, p.Type__TypeElement-sc-goli3j-0.ieTwfQ,
p.Type__TypeElement-goli3j-0 { p.Type__TypeElement-goli3j-0,
p.Text__TextElement-sc-if376j-0,
p.Type__TypeElement-sc-goli3j-0 {
color: var(--musixmatch) !important; color: var(--musixmatch) !important;
} }
@@ -26,7 +30,8 @@ p.Type__TypeElement-goli3j-0 {
} }
/* fix previous lyrics for old versions */ /* fix previous lyrics for old versions */
.H2J92dVdr0ykdOX5azL1 { .H2J92dVdr0ykdOX5azL1,
.KnFq2ijXFdOtyl4Iebjv {
color: var(--past) !important; color: var(--past) !important;
opacity: 1 !important; opacity: 1 !important;
} }
@@ -34,7 +39,8 @@ p.Type__TypeElement-goli3j-0 {
/* hover */ /* hover */
.vapgYYF2HMEeLJuOWGq5:hover, .vapgYYF2HMEeLJuOWGq5:hover,
._LKG3z7SnerR0eigPCoK:hover, ._LKG3z7SnerR0eigPCoK:hover,
.NHVfxGs2HwmI_fly2JC4:hover { .NHVfxGs2HwmI_fly2JC4:hover,
.gaHIufRWhoWbiT8S6zuM:hover {
color: var(--hover) !important; color: var(--hover) !important;
} }
@@ -42,7 +48,9 @@ p.Type__TypeElement-goli3j-0 {
.HxblHEsl2WX2yhubfVIc, .HxblHEsl2WX2yhubfVIc,
.SruqsAzX8rUtY2isUZDF, .SruqsAzX8rUtY2isUZDF,
.AEfhRyqGa3vzQrgfdwWE.Re403AJffPPuZmX7LRJj, .AEfhRyqGa3vzQrgfdwWE.Re403AJffPPuZmX7LRJj,
.NHVfxGs2HwmI_fly2JC4.E64X_eoy6xsJmDdKKHja { .NHVfxGs2HwmI_fly2JC4.E64X_eoy6xsJmDdKKHja,
.gaHIufRWhoWbiT8S6zuM.Qo3OkrSis5IWlP9Tchbr,
.AEfhRyqGa3vzQrgfdwWE .Re403AJffPPuZmX7LRJj {
color: var(--next) !important; color: var(--next) !important;
} }
@@ -56,7 +64,7 @@ p.Type__TypeElement-goli3j-0 {
.C3pBU1DsOUJJOAv89ZFT, .C3pBU1DsOUJJOAv89ZFT,
.T67LFP0PElpfkkLuegQt, .T67LFP0PElpfkkLuegQt,
.e7eFLioNSG5PAi1qVFT4 { .e7eFLioNSG5PAi1qVFT4 {
color: var(--past) !important; color: var(--musixmatch) !important;
} }
/* full screen lyrics */ /* full screen lyrics */

View File

@@ -1577,76 +1577,6 @@
} }
} }
}, },
"lyricscolor1": {
"version": {
"fr": "1.1.85",
"to": "1.1.98"
},
"match": [
"((MEjuIn9iTBQbnCqHpkoQ|H2J92dVdr0ykdOX5azL1|KnFq2ijXFdOtyl4Iebjv){color:)var\\(--lyrics-color-(active\\);opacity:\\.{0,1}\\d|passed\\))",
"((TDPh45khCfG51fNwNIiw|E64X_eoy6xsJmDdKKHja|arY01KDGhWNgzlAHlhpd|t0iEG6xYBDhK_mFvkCp0){color:)var\\(--lyrics-color-active\\)",
"((NHVfxGs2HwmI_fly2JC4|NiCdLCpp3o2z6nBrayOn|gaHIufRWhoWbiT8S6zuM){color:)var\\(--lyrics-color-inactive\\)",
"var\\(--lyrics-color-background\\)",
"((NHVfxGs2HwmI_fly2JC4|NiCdLCpp3o2z6nBrayOn|gaHIufRWhoWbiT8S6zuM):hover{color:)var\\(--lyrics-color-active\\)",
"((iq4cgi0YEKr6DGaTtzUj|kGR_hu4tdj9PnUlSPaRL|W_EplVEAbZrZURqfLiQC|OYiGFGZJDIZ4FF4ZTDK2){color:)var\\(--lyrics-color-inactive\\)"
],
"replace": [
"",
"",
"",
"",
"",
""
]
},
"lyricscolor2": {
"version": {
"fr": "1.1.99",
"to": "1.2.44"
},
"add": [
" .npv-lyrics__text-wrapper--previous .npv-lyrics__text {color:{0} !important;}",
" .npv-lyrics__text-wrapper--current .npv-lyrics__text {color:{0} !important;}",
" .npv-lyrics__text-wrapper--next .npv-lyrics__text {color:{0} !important;}",
"{0}{1}{2}"
],
"match": [
"(.--lyrics-color-background.:(..|..colors.)background)",
"(.--lyrics-color-passed.:)(..passed|.{5,8}fromCSS.+?RGBA\\))",
"(.--lyrics-color-active.:)((?:.\\?.\\.passed:.{2,13}active(Text)?|.{2,13}active(Text)?|.{2,13}colors.activeText))",
"(.--lyrics-color-inactive.:)(..inactive|..colors.text)",
"(.--lyrics-color-background.:)((..|..colors.)background)",
"(.--lyrics-color-hover.:)(\"xxx\")",
"(.--lyrics-color-maxmatch.:)(\"xxx\")",
"(color:)(.{1,4}colors.text)(},children:.{1,8}get\\(\"web-player.lyrics.unsynced\"\\))",
"\\?(.{1,2}\\.colors.background):"
],
"replace": [
"$1,\"--lyrics-color-hover\":\"xxx\",\"--lyrics-color-maxmatch\":\"xxx\"",
"",
"",
"",
"",
"",
"",
"",
"?\"{0}\":"
]
},
"fixcsslyricscolor2": {
"version": {
"fr": "1.1.99",
"to": "1.2.44"
},
"match": [
"(:hover{color:var)\\(--lyrics-color-active\\)",
"((?:kGR_hu4tdj9PnUlSPaRL|LomBcMvfM8AEmZGquAdj){color:var)\\(--lyrics-color-inactive\\)"
],
"replace": [
"$1(--lyrics-color-hover)!important",
"$1(--lyrics-color-maxmatch)!important"
]
},
"collaboration": { "collaboration": {
"version": { "version": {
"fr": "1.1.73", "fr": "1.1.73",

149
run.ps1
View File

@@ -1064,55 +1064,6 @@ function Helper($paramname) {
$contents = "disablesentry" $contents = "disablesentry"
$json = $webjson.others $json = $webjson.others
} }
"Lyrics-color" {
$pasttext = $webjson.others.themelyrics.theme.$lyrics_stat.pasttext
$current = $webjson.others.themelyrics.theme.$lyrics_stat.current
$next = $webjson.others.themelyrics.theme.$lyrics_stat.next
$background = $webjson.others.themelyrics.theme.$lyrics_stat.background
$hover = $webjson.others.themelyrics.theme.$lyrics_stat.hover
$maxmatch = $webjson.others.themelyrics.theme.$lyrics_stat.maxmatch
if ([version]$offline -lt [version]"1.1.99.871") { $lyrics = "lyricscolor1"; $contents = $lyrics }
if ([version]$offline -ge [version]"1.1.99.871") { $lyrics = "lyricscolor2"; $contents = $lyrics }
# xpui.js or xpui-routes-lyrics.js
if ([version]$offline -ge [version]"1.1.99.871") {
$full_previous = Mod-F -template $webjson.others.$lyrics.add[0] -arguments $pasttext
$full_current = Mod-F -template $webjson.others.$lyrics.add[1] -arguments $current
$full_next = Mod-F -template $webjson.others.$lyrics.add[2] -arguments $next
$full_lyrics = Mod-F -template $webjson.others.$lyrics.add[3] -arguments $full_previous, $full_current, $full_next
$webjson.others.$lyrics.add[3] = $full_lyrics
$webjson.others.$lyrics.replace[1] = '$1' + '"' + $pasttext + '"'
$webjson.others.$lyrics.replace[2] = '$1' + '"' + $current + '"'
$webjson.others.$lyrics.replace[3] = '$1' + '"' + $next + '"'
$webjson.others.$lyrics.replace[4] = '$1' + '"' + $background + '"'
$webjson.others.$lyrics.replace[5] = '$1' + '"' + $hover + '"'
$webjson.others.$lyrics.replace[6] = '$1' + '"' + $maxmatch + '"'
if ([version]$offline -ge [version]"1.2.6.861") {
$webjson.others.$lyrics.replace[7] = '$1' + '"' + $maxmatch + '"' + '$3'
}
else {
$webjson.others.$lyrics.match = $webjson.others.$lyrics.match | Where-Object { $_ -ne $webjson.others.$lyrics.match[7] }
}
if ([version]$offline -ge [version]"1.2.3.1107") {
$webjson.others.$lyrics.replace[8] = $webjson.others.$lyrics.replace[8] -f $background
}
}
# xpui-routes-lyrics.css
if ([version]$offline -lt [version]"1.1.99.871") {
$webjson.others.$lyrics.replace[0] = '$1' + $pasttext
$webjson.others.$lyrics.replace[1] = '$1' + $current
$webjson.others.$lyrics.replace[2] = '$1' + $next
$webjson.others.$lyrics.replace[3] = $background
$webjson.others.$lyrics.replace[4] = '$1' + $hover
$webjson.others.$lyrics.replace[5] = '$1' + $maxmatch
}
$name = "patches.json.others."
$n = $name_file
$json = $webjson.others
}
"Discriptions" { "Discriptions" {
# Add discriptions (xpui-desktop-modals.js) # Add discriptions (xpui-desktop-modals.js)
@@ -1502,31 +1453,39 @@ function injection {
[string]$FolderInArchive, [string]$FolderInArchive,
[Alias("n")] [Alias("n")]
[string]$FileName, [string[]]$FileNames,
[Alias("c")] [Alias("c")]
[string]$FileContent [string[]]$FileContents,
[Alias("i")]
[string[]]$FilesToInject # force only specific file/files to connect index.html otherwise all will be connected
) )
$folderPathInArchive = "$($FolderInArchive)/" $folderPathInArchive = "$($FolderInArchive)/"
Add-Type -AssemblyName System.IO.Compression.FileSystem Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::Open($ArchivePath, 'Update') $archive = [System.IO.Compression.ZipFile]::Open($ArchivePath, 'Update')
$stream = $null
try { try {
$entry = $archive.GetEntry($folderPathInArchive + $FileName) for ($i = 0; $i -lt $FileNames.Length; $i++) {
if ($entry -eq $null) { $fileName = $FileNames[$i]
$stream = $archive.CreateEntry($folderPathInArchive + $FileName).Open() $fileContent = $FileContents[$i]
}
else {
$stream = $entry.Open()
}
$writer = [System.IO.StreamWriter]::new($stream) $entry = $archive.GetEntry($folderPathInArchive + $fileName)
$writer.Write($FileContent) if ($entry -eq $null) {
$stream = $archive.CreateEntry($folderPathInArchive + $fileName).Open()
}
else {
$stream = $entry.Open()
}
$writer.Dispose() $writer = [System.IO.StreamWriter]::new($stream)
$stream.Dispose() $writer.Write($fileContent)
$writer.Dispose()
$stream.Dispose()
}
$indexEntry = $archive.Entries | Where-Object { $_.FullName -eq "index.html" } $indexEntry = $archive.Entries | Where-Object { $_.FullName -eq "index.html" }
if ($indexEntry -ne $null) { if ($indexEntry -ne $null) {
@@ -1536,22 +1495,33 @@ function injection {
$reader.Dispose() $reader.Dispose()
$indexStream.Dispose() $indexStream.Dispose()
$headTagIndex = $indexContent.IndexOf("</head>")
$scriptTagIndex = $indexContent.IndexOf("<script") $scriptTagIndex = $indexContent.IndexOf("<script")
if ($scriptTagIndex -ge 0) { if ($headTagIndex -ge 0 -or $scriptTagIndex -ge 0) {
$filesToInject = if ($FilesToInject) { $FilesToInject } else { $FileNames }
$modifiedIndexContent = $indexContent.Insert($scriptTagIndex, "<script defer=`"defer`" src=`"/$FolderInArchive/$FileName`"></script>") foreach ($fileName in $filesToInject) {
if ($fileName.EndsWith(".js")) {
$modifiedIndexContent = $indexContent.Insert($scriptTagIndex, "<script defer=`"defer`" src=`"/$FolderInArchive/$fileName`"></script>")
$indexContent = $modifiedIndexContent
}
elseif ($fileName.EndsWith(".css")) {
$modifiedIndexContent = $indexContent.Insert($headTagIndex, "<link href=`"/$FolderInArchive/$fileName`" rel=`"stylesheet`">")
$indexContent = $modifiedIndexContent
}
}
$indexEntry.Delete() $indexEntry.Delete()
$newIndexEntry = $archive.CreateEntry("index.html").Open() $newIndexEntry = $archive.CreateEntry("index.html").Open()
$indexWriter = [System.IO.StreamWriter]::new($newIndexEntry) $indexWriter = [System.IO.StreamWriter]::new($newIndexEntry)
$indexWriter.Write($modifiedIndexContent) $indexWriter.Write($indexContent)
$indexWriter.Dispose() $indexWriter.Dispose()
$newIndexEntry.Dispose() $newIndexEntry.Dispose()
} }
else { else {
Write-Warning "<script tag was not found in the index.html file in the archive." Write-Warning "<script or </head> tag was not found in the index.html file in the archive."
} }
} }
else { else {
@@ -1566,6 +1536,7 @@ function injection {
} }
Write-Host ($lang).ModSpoti`n Write-Host ($lang).ModSpoti`n
$tempDirectory = $PWD $tempDirectory = $PWD
@@ -1704,6 +1675,21 @@ If ($test_spa) {
} }
} }
# Static color for lyrics
if ($lyrics_stat) {
$rulesContent = Get -Url (Get-Link -e "/css-helper/lyrics-color/rules.css")
$colorsContent = Get -Url (Get-Link -e "/css-helper/lyrics-color/colors.css")
$colorsContent = $colorsContent -replace '{{past}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.pasttext)"
$colorsContent = $colorsContent -replace '{{current}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.current)"
$colorsContent = $colorsContent -replace '{{next}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.next)"
$colorsContent = $colorsContent -replace '{{hover}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.hover)"
$colorsContent = $colorsContent -replace '{{background}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.background)"
$colorsContent = $colorsContent -replace '{{musixmatch}}', "$($webjson.others.themelyrics.theme.$lyrics_stat.maxmatch)"
injection -p $xpui_spa_patch -f "spotx-helper/lyrics-color" -n @("rules.css", "colors.css") -c @($rulesContent, $colorsContent) -i "rules.css"
}
extract -counts 'one' -method 'zip' -name 'xpui.js' -helper 'VariousofXpui-js' extract -counts 'one' -method 'zip' -name 'xpui.js' -helper 'VariousofXpui-js'
if ($devtools -and [version]$offline -ge [version]"1.2.35.663") { if ($devtools -and [version]$offline -ge [version]"1.2.35.663") {
@@ -1715,29 +1701,6 @@ If ($test_spa) {
extract -counts 'one' -method 'zip' -name 'xpui-routes-playlist.js' -helper 'Collaborators' extract -counts 'one' -method 'zip' -name 'xpui-routes-playlist.js' -helper 'Collaborators'
} }
# Static color for lyrics
if ($lyrics_stat) {
# old
if ([version]$offline -lt [version]"1.1.99.871") {
$name_file = 'xpui-routes-lyrics.css'
extract -counts 'one' -method 'zip' -name $name_file -helper 'Lyrics-color'
}
# new
if ([version]$offline -ge [version]"1.1.99.871") {
$contents = "fixcsslyricscolor2"
extract -counts 'one' -method 'zip' -name 'xpui.css' -helper 'FixCss'
if ([version]$offline -le [version]"1.2.2.582") {
$name_file = 'xpui-routes-lyrics.js'
extract -counts 'one' -method 'zip' -name $name_file -helper 'Lyrics-color'
}
}
# mini lyrics
if ([version]$offline -ge [version]"1.2.0.1155") {
$name_file = 'xpui.js'
extract -counts 'one' -method 'zip' -name $name_file -helper 'Lyrics-color'
}
}
# Add discriptions (xpui-desktop-modals.js) # Add discriptions (xpui-desktop-modals.js)
extract -counts 'one' -method 'zip' -name 'xpui-desktop-modals.js' -helper 'Discriptions' extract -counts 'one' -method 'zip' -name 'xpui-desktop-modals.js' -helper 'Discriptions'
@@ -1762,13 +1725,9 @@ If ($test_spa) {
$css += $webjson.others.veryhighstream.add $css += $webjson.others.veryhighstream.add
} }
} }
# Full screen lyrics
if ($lyrics_stat -and [version]$offline -ge [version]"1.2.3.1107" -and [version]$offline -le [version]"1.2.44.405") {
$css += $webjson.others.lyricscolor2.add[3]
}
if ($null -ne $css ) { extract -counts 'one' -method 'zip' -name 'xpui.css' -add $css } if ($null -ne $css ) { extract -counts 'one' -method 'zip' -name 'xpui.css' -add $css }
# Old UI fix # Old UI fix
$contents = "fix-old-theme" $contents = "fix-old-theme"
extract -counts 'one' -method 'zip' -name 'xpui.css' -helper "FixCss" extract -counts 'one' -method 'zip' -name 'xpui.css' -helper "FixCss"