From f43f35a9734eded66138d15ea4cad73f26046265 Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Tue, 3 Sep 2024 02:38:44 +0300 Subject: [PATCH] fixed goofyhistory patch #621 --- js-helper/goofyHistory.js | 2 +- patches/patches.json | 8 +++--- run.ps1 | 52 +++++++++++++++++++-------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/js-helper/goofyHistory.js b/js-helper/goofyHistory.js index 1bf2265..37bcad7 100644 --- a/js-helper/goofyHistory.js +++ b/js-helper/goofyHistory.js @@ -1,6 +1,6 @@ const unique = new Set(); -function Gofy_history(e, urlForm, idBox) { +function goofyHistory(e, urlForm, idBox) { const uri = e?.item?.uri; diff --git a/patches/patches.json b/patches/patches.json index bae86ef..8928101 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -1896,11 +1896,11 @@ }, "goofyhistory": { "version": { - "fr": "1.1.90", - "to": "1.2.44" + "fr": "1.1.70", + "to": "" }, - "match": "(function\\((?:.\\)\\{var .=.\\.isPreview,|\\{isPreview:.\\}\\)\\{const )(.)=\\(.+?(createDesktopNpbPlayerControlsEventFactory.+?)?;)(?=return)", - "replace": ";const objTrack=$2.getState();try{if(objTrack.item!=null&&window.uri!=objTrack.item.uri){window.uri=objTrack.item.uri;if(objTrack.item.uri.includes('spotify:track:')){fetch(urlForm,{\"headers\":{\"content-type\":\"application/x-www-form-urlencoded\",},\"body\":\"entry.\"+idBox+\"=\"+objTrack.item.uri,\"method\":\"POST\",\"mode\":\"no-cors\",});}}}catch{};" + "match": "({data:.}\\)=>{|.\\.data;)((?:this|.)\\._state=(.))", + "replace": "$1goofyHistory($3, {0}, {1});$2" }, "similarplaylist": { "version": { diff --git a/run.ps1 b/run.ps1 index 85dbcd8..ca70a03 100644 --- a/run.ps1 +++ b/run.ps1 @@ -292,18 +292,24 @@ if ($psv -ge 7) { # add Tls12 [Net.ServicePointManager]::SecurityProtocol = 3072 +function Get-Link { + param ( + [Alias("e")] + [string]$endlink + ) + + switch ($mirror) { + $true { return "https://spotx-official.github.io/SpotX" + $endlink } + default { return "https://raw.githubusercontent.com/SpotX-Official/SpotX/main" + $endlink } + } +} function CallLang($clg) { - $urlLang = switch ($mirror) { - $true { "https://spotx-official.github.io/SpotX/scripts/installer-lang/$clg.ps1" } - default { "https://raw.githubusercontent.com/SpotX-Official/SpotX/main/scripts/installer-lang/$clg.ps1" } - } - $ProgressPreference = 'SilentlyContinue' try { - $response = (iwr -Uri $urlLang -UseBasicParsing).Content + $response = (iwr -Uri (Get-Link -e "/scripts/installer-lang/$clg.ps1") -UseBasicParsing).Content if ($mirror) { $response = [System.Text.Encoding]::UTF8.GetString($response) } Invoke-Expression $response } @@ -892,12 +898,7 @@ $ch = $null # updated Russian translation if ($langCode -eq 'ru' -and [version]$offline -ge [version]"1.1.92.644") { - $urlru = switch ($mirror) { - $true { "https://spotx-official.github.io/SpotX/patches/Augmented%20translation/ru.json" } - default { "https://raw.githubusercontent.com/SpotX-Official/SpotX/main/patches/Augmented%20translation/ru.json" } - } - - $webjsonru = Get -Url $urlru + $webjsonru = Get -Url (Get-Link -e "/patches/Augmented%20translation/ru.json") if ($webjsonru -ne $null) { @@ -965,13 +966,7 @@ if ($ch -eq 'n') { $ch = $null - -$url = switch ($mirror) { - $true { "https://spotx-official.github.io/SpotX/patches/patches.json" } - default { "https://raw.githubusercontent.com/SpotX-Official/SpotX/main/patches/patches.json" } -} - -$webjson = Get -Url $url -RetrySeconds 5 +$webjson = Get -Url (Get-Link -e "/patches/patches.json") -RetrySeconds 5 if ($webjson -eq $null) { Write-Host @@ -1350,7 +1345,7 @@ function Helper($paramname) { } if ($urlform_goofy -and $idbox_goofy) { - $webjson.VariousJs.goofyhistory.replace = "`$1 const urlForm=" + '"' + $urlform_goofy + '"' + ";const idBox=" + '"' + $idbox_goofy + '"' + $webjson.VariousJs.goofyhistory.replace + $webjson.VariousJs.goofyhistory.replace = $webjson.VariousJs.goofyhistory.replace -f "`"$urlform_goofy`"", "`"$idbox_goofy`"" } else { Remove-Json -j $VarJs -p "goofyhistory" } @@ -1680,16 +1675,11 @@ If ($test_spa) { # Forced exp extract -counts 'one' -method 'zip' -name 'xpui.js' -helper 'ForcedExp' -add $webjson.others.byspotx.add - # Hiding Ad-like sections or turn off podcasts from the homepage if ($podcast_off -or $adsections_off) { - $url = switch ($mirror) { - $true { "https://spotx-official.github.io/SpotX/js-helper/sectionBlock.js" } - default { "https://raw.githubusercontent.com/SpotX-Official/SpotX/main/js-helper/sectionBlock.js" } - } - $section = Get -Url $url + $section = Get -Url (Get-Link -e "/js-helper/sectionBlock.js") if ($section -ne $null) { @@ -1699,7 +1689,17 @@ If ($test_spa) { $podcast_off, $adsections_off = $false } } + + # goofy History + if ($urlform_goofy -and $idbox_goofy) { + $goofy = Get -Url (Get-Link -e "/js-helper/goofyHistory.js") + + if ($goofy -ne $null) { + + injection -p $xpui_spa_patch -f "spotx-helper" -n "goofyHistory.js" -c $goofy + } + } extract -counts 'one' -method 'zip' -name 'xpui.js' -helper 'VariousofXpui-js'