From cd140c94e070440fe32ddd0861667430ba32656a Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Sun, 11 May 2025 20:59:56 +0300 Subject: [PATCH] added parameter canvashome_off - added parameter canvashome_off, to disable sections with canvases on the main page --- js-helper/sectionBlock.js | 38 ++++++++++++++++++++++++++-------- run.ps1 | 43 ++++++++++++++++++++++++++------------- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/js-helper/sectionBlock.js b/js-helper/sectionBlock.js index 59f5186..fde112b 100644 --- a/js-helper/sectionBlock.js +++ b/js-helper/sectionBlock.js @@ -4,7 +4,6 @@ function sectionBlock(e, type) { const sections = body?.sectionContainer?.sections?.items; function removeSections() { - const sectionsData = [ { id: '0JQ5IMCbQBLupUQrQFeCzx', name: 'Best of the Year' }, { id: '0JQ5DAnM3wGh0gz1MXnu3C', name: 'Best of Artists / Tracks' }, @@ -34,7 +33,7 @@ function sectionBlock(e, type) { { id: '0JQ5IMCbQBLqTJyy28YCa9', name: '?' }, { id: '0JQ5IMCbQBLlC31GvtaB6w', name: '?' }, { id: '0JQ5DAnM3wGh0gz1MXnu7R', name: '?' } - ] + ]; const sectionIdsRegex = new RegExp(sectionsData.map(section => section.id).join('|')); for (let i = sections.length - 1; i >= 0; i--) { @@ -64,13 +63,34 @@ function sectionBlock(e, type) { } } - if (body?.greeting && sections) { - if (type === "section" || type === "all") { - removeSections(); - } + function removeCanvasSections() { + if (Array.isArray(sections)) { + for (let i = sections.length - 1; i >= 0; i--) { - if (type === "podcast" || type === "all") { - removePodcasts(); + const sectionDataTypename = sections[i]?.data?.__typename; + + if (sectionDataTypename === 'HomeFeedBaselineSectionData') { + sections.splice(i, 1); + } + } } } -} + + if (body?.greeting && sections) { + const actions = { + section: removeSections, + podcast: removePodcasts, + canvas: removeCanvasSections, + all: () => { + removeSections(); + removePodcasts(); + removeCanvasSections(); + } + }; + if (Array.isArray(type)) { + type.forEach(t => actions[t]?.()); + } else { + actions[type]?.(); + } + } +} \ No newline at end of file diff --git a/run.ps1 b/run.ps1 index af06073..04daa39 100644 --- a/run.ps1 +++ b/run.ps1 @@ -13,13 +13,16 @@ param [Alias("dev")] [switch]$devtools, - [Parameter(HelpMessage = 'Hiding podcasts/episodes/audiobooks from homepage.')] + [Parameter(HelpMessage = 'Disable podcasts/episodes/audiobooks from homepage.')] [switch]$podcasts_off, - [Parameter(HelpMessage = 'Hiding Ad-like sections from the homepage')] + [Parameter(HelpMessage = 'Disable Ad-like sections from homepage')] [switch]$adsections_off, + + [Parameter(HelpMessage = 'Disable canvas from homepage')] + [switch]$canvashome_off, - [Parameter(HelpMessage = 'Do not hiding podcasts/episodes/audiobooks from homepage.')] + [Parameter(HelpMessage = 'Do not disable podcasts/episodes/audiobooks from homepage.')] [switch]$podcasts_on, [Parameter(HelpMessage = 'Block Spotify automatic updates.')] @@ -73,9 +76,6 @@ param [Parameter(HelpMessage = 'it`s killing the heart icon, you`re able to save and choose the destination for any song, playlist, or podcast')] [switch]$plus, - [Parameter(HelpMessage = 'Enabled the big cards for home page')] - [switch]$canvasHome, - [Parameter(HelpMessage = 'Enable funny progress bar.')] [switch]$funnyprogressBar, @@ -1168,8 +1168,6 @@ function Helper($paramname) { if ([version]$offline -le [version]'1.2.62.580') { - if (!($canvasHome)) { Move-Json -n "canvasHome", "canvasHomeAudioPreviews" -t $Enable -f $Disable } - if (!$newFullscreenMode) { Move-Json -n "ImprovedCinemaMode", "ImprovedCinemaModeCanvas" -t $Enable -f $Disable } } @@ -1380,14 +1378,31 @@ function Helper($paramname) { else { Remove-Json -j $VarJs -p 'product_state' } - if ($podcast_off -or $adsections_off) { - $type = switch ($true) { - { $podcast_off -and $adsections_off } { "all" } - { $podcast_off -and -not $adsections_off } { "podcast" } - { -not $podcast_off -and $adsections_off } { "section" } + $type = $null + + if ($podcast_off -or $adsections_off -or $canvashome_off) { + + $active_elements = @() + if ($podcast_off) { $active_elements += "podcast" } + if ($adsections_off) { $active_elements += "section" } + if ($canvashome_off) { $active_elements += "canvas" } + + switch ($active_elements.Count) { + 3 { + $type = "all" + } + 2 { + $type = '[' + (($active_elements | ForEach-Object { "`"$_`"" }) -join ", ") + ']' + $webjson.VariousJs.block_section.replace = $webjson.VariousJs.block_section.replace -replace '\"', '' + } + 1 { + $type = $active_elements[0] + } } + $webjson.VariousJs.block_section.replace = $webjson.VariousJs.block_section.replace -f $type $global:type = $type + } else { Remove-Json -j $VarJs -p 'block_section' @@ -1787,7 +1802,7 @@ If ($test_spa) { } } # block subfeeds - if ($global:type -eq "all" -or $global:type -eq "podcast") { + if ($global:type -match "all" -or $global:type -match "podcast") { $css += $webjson.others.block_subfeeds.add } # scrollbar indent fixes