From 8e69ee9f0751ecb6ab5ac189955633f17c3fbc32 Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Fri, 13 Sep 2024 22:48:14 +0300 Subject: [PATCH] static lyrics refactoring --- css-helper/lyrics-color/rules.css | 20 ++-- patches/patches.json | 70 -------------- run.ps1 | 149 +++++++++++------------------- 3 files changed, 68 insertions(+), 171 deletions(-) diff --git a/css-helper/lyrics-color/rules.css b/css-helper/lyrics-color/rules.css index e550795..be08042 100644 --- a/css-helper/lyrics-color/rules.css +++ b/css-helper/lyrics-color/rules.css @@ -1,7 +1,9 @@ @import url('colors.css'); + /* mini lyrics */ .I2WIloMMjsBeMaIS8H3v, -.McI3hD7aCfpq015LJa6X { +.McI3hD7aCfpq015LJa6X, +.gpDSOimnzH4zTJmE7UR5 { --lyrics-color-active: var(--current) !important; --lyrics-color-inactive: var(--next) !important; --lyrics-color-passed: var(--past) !important; @@ -11,7 +13,9 @@ /* musixmatch */ p.encore-text.encore-text-body-small, 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; } @@ -26,7 +30,8 @@ p.Type__TypeElement-goli3j-0 { } /* fix previous lyrics for old versions */ -.H2J92dVdr0ykdOX5azL1 { +.H2J92dVdr0ykdOX5azL1, +.KnFq2ijXFdOtyl4Iebjv { color: var(--past) !important; opacity: 1 !important; } @@ -34,7 +39,8 @@ p.Type__TypeElement-goli3j-0 { /* hover */ .vapgYYF2HMEeLJuOWGq5:hover, ._LKG3z7SnerR0eigPCoK:hover, -.NHVfxGs2HwmI_fly2JC4:hover { +.NHVfxGs2HwmI_fly2JC4:hover, +.gaHIufRWhoWbiT8S6zuM:hover { color: var(--hover) !important; } @@ -42,7 +48,9 @@ p.Type__TypeElement-goli3j-0 { .HxblHEsl2WX2yhubfVIc, .SruqsAzX8rUtY2isUZDF, .AEfhRyqGa3vzQrgfdwWE.Re403AJffPPuZmX7LRJj, -.NHVfxGs2HwmI_fly2JC4.E64X_eoy6xsJmDdKKHja { +.NHVfxGs2HwmI_fly2JC4.E64X_eoy6xsJmDdKKHja, +.gaHIufRWhoWbiT8S6zuM.Qo3OkrSis5IWlP9Tchbr, +.AEfhRyqGa3vzQrgfdwWE .Re403AJffPPuZmX7LRJj { color: var(--next) !important; } @@ -56,7 +64,7 @@ p.Type__TypeElement-goli3j-0 { .C3pBU1DsOUJJOAv89ZFT, .T67LFP0PElpfkkLuegQt, .e7eFLioNSG5PAi1qVFT4 { - color: var(--past) !important; + color: var(--musixmatch) !important; } /* full screen lyrics */ diff --git a/patches/patches.json b/patches/patches.json index afdb2a9..243afbf 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -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": { "version": { "fr": "1.1.73", diff --git a/run.ps1 b/run.ps1 index 04016a9..b9e0371 100644 --- a/run.ps1 +++ b/run.ps1 @@ -1064,55 +1064,6 @@ function Helper($paramname) { $contents = "disablesentry" $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" { # Add discriptions (xpui-desktop-modals.js) @@ -1502,31 +1453,39 @@ function injection { [string]$FolderInArchive, [Alias("n")] - [string]$FileName, + [string[]]$FileNames, [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)/" Add-Type -AssemblyName System.IO.Compression.FileSystem $archive = [System.IO.Compression.ZipFile]::Open($ArchivePath, 'Update') - $stream = $null + try { - $entry = $archive.GetEntry($folderPathInArchive + $FileName) - if ($entry -eq $null) { - $stream = $archive.CreateEntry($folderPathInArchive + $FileName).Open() - } - else { - $stream = $entry.Open() - } + for ($i = 0; $i -lt $FileNames.Length; $i++) { + $fileName = $FileNames[$i] + $fileContent = $FileContents[$i] - $writer = [System.IO.StreamWriter]::new($stream) - $writer.Write($FileContent) + $entry = $archive.GetEntry($folderPathInArchive + $fileName) + if ($entry -eq $null) { + $stream = $archive.CreateEntry($folderPathInArchive + $fileName).Open() + } + else { + $stream = $entry.Open() + } - $writer.Dispose() - $stream.Dispose() + $writer = [System.IO.StreamWriter]::new($stream) + $writer.Write($fileContent) + + $writer.Dispose() + $stream.Dispose() + } $indexEntry = $archive.Entries | Where-Object { $_.FullName -eq "index.html" } if ($indexEntry -ne $null) { @@ -1536,22 +1495,33 @@ function injection { $reader.Dispose() $indexStream.Dispose() + $headTagIndex = $indexContent.IndexOf("") $scriptTagIndex = $indexContent.IndexOf("") + foreach ($fileName in $filesToInject) { + if ($fileName.EndsWith(".js")) { + $modifiedIndexContent = $indexContent.Insert($scriptTagIndex, "") + $indexContent = $modifiedIndexContent + } + elseif ($fileName.EndsWith(".css")) { + $modifiedIndexContent = $indexContent.Insert($headTagIndex, "") + $indexContent = $modifiedIndexContent + } + } $indexEntry.Delete() $newIndexEntry = $archive.CreateEntry("index.html").Open() $indexWriter = [System.IO.StreamWriter]::new($newIndexEntry) - $indexWriter.Write($modifiedIndexContent) + $indexWriter.Write($indexContent) $indexWriter.Dispose() $newIndexEntry.Dispose() } else { - Write-Warning "