Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
- fix and refactoring of the patch for hiding podcasts and sections that look like ads on the main page
- added homesub_off parameter to hide additional filters at the top of the main page
- minor changes in code
  • Loading branch information
amd64fox committed Mar 14, 2024
1 parent ba3d4c8 commit 1774024
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 100 deletions.
71 changes: 71 additions & 0 deletions js-helper/sectionBlock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
function sectionBlock(e, type) {

const body = e?.data?.home;
const sections = body?.sectionContainer?.sections?.items;

function removeSections() {

const sectionsData = [
{ id: '0JQ5IMCbQBLupUQrQFeCzx', name: 'Best of the Year' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3C', name: 'Best of Artists / Tracks' },
{ id: '0JQ5DAnM3wGh0gz1MXnu4w', name: 'Best of songwriters' },
{ id: '0JQ5DAob0KOew1FBAMSmBz', name: 'Featured Charts' },
{ id: '0JQ5DAob0JCuWaGLU6ntFY', name: 'Focus' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3s', name: 'Fresh new music' },
{ id: '0JQ5DAob0LaV9FOMJ9utY5', name: 'Gaming music' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3q', name: 'Happy' },
{ id: '0JQ5DAnM3wGh0gz1MXnucG', name: 'Mood' },
{ id: '0JQ5DAob0JCuWaGLU6ntFT', name: 'Mood' },
{ id: '0JQ5DAob0Jr9ClCbkV4pZD', name: 'Music to game to' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3B', name: 'Popular Albums / Artists' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3D', name: 'Popular new releases' },
{ id: '0JQ5DAnM3wGh0gz1MXnu4h', name: 'Popular radio' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3u', name: 'Sad' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3w', name: 'Throwback' },
{ id: '0JQ5DAuChZYPe9iDhh2mJz', name: 'Throwback Thursday' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3M', name: 'Today`s biggest hits' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3E', name: 'Trending now' },
{ id: '0JQ5DAnM3wGh0gz1MXnu3x', name: 'Workout' },
{ 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--) {
const uri = sections[i]?.uri;
if (uri && uri.match(sectionIdsRegex)) {
sections.splice(i, 1);
}
}
}

function removePodcasts() {
if (Array.isArray(sections)) {
for (let i = 0; i < sections.length; i++) {
const sectionItems = sections[i]?.sectionItems?.items;

if (Array.isArray(sectionItems)) {
for (let j = 0; j < sectionItems.length; j++) {
const contentData = sectionItems[j]?.content?.data;

if (contentData && ["Podcast", "Audiobook", "Episode"].includes(contentData.__typename)) {
sectionItems.splice(j, 1);
j--;
}
}
}
}
}
}

if (body?.greeting && sections) {
if (type === "section" || type === "all") {
removeSections();
}

if (type === "podcast" || type === "all") {
removePodcasts();
}
}
}
59 changes: 26 additions & 33 deletions patches/patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,24 @@
}
},
"EnableExp": {
"HomeViaGraphQLV2": {
"name": "enableHomeViaGraphQLV2",
"description": "Enable fetching Home via GraphQL",
"native_description": "Enable fetching Home via GraphQL",
"version": {
"fr": "1.1.86",
"to": "1.1.92"
}
},
"BrowseViaPathfinder": {
"name": "enableBrowseViaPathfinder",
"description": "Fixes a bug on the genres page",
"native_description": "Fetch Browse data from Pathfinder",
"version": {
"fr": "1.1.88",
"to": "1.2.24"
}
},
"EnhanceLikedSongs": {
"name": "enableEnhanceLikedSongs",
"description": "Enable Enhance Liked Songs UI and functionality",
Expand Down Expand Up @@ -862,15 +880,6 @@
"to": "1.2.29"
}
},
"BrowseViaPathfinder": {
"name": "enableBrowseViaPathfinder",
"description": "Fixes a bug on the genres page",
"native_description": "Fetch Browse data from Pathfinder",
"version": {
"fr": "1.1.70",
"to": "1.2.24"
}
},
"NotificationCenter": {
"name": "enableNotificationCenter",
"description": "Enables notification center for desktop & web",
Expand Down Expand Up @@ -1130,30 +1139,6 @@
"replace": "dodo"
}
},
"podcastsoff": {
"version": {
"fr": "1.1.70",
"to": "1.1.92"
},
"match": "withQueryParameters\\(.\\){return this.queryParameters=.,this}",
"replace": "withQueryParameters(e){return this.queryParameters=(e.types?{...e, types: e.types.split(\",\").filter(_ => ![\"episode\",\"show\"].includes(_)).join(\",\")}:e),this}"
},
"podcastsoff2": {
"version": {
"fr": "1.1.93",
"to": ""
},
"match": "(\\!?Array.isArray\\(.\\)[\\|&]{2}.===(.).length\\)return null;)",
"replace": "$1 let as=$2;if(!Array.isArray(as)){as=e;}for(let q=0;q<(as.children?as.children.length:as.length);q++){const key=(as.children?.[q]||as[q])?.key;if(!key||as[q].props?.value===\"search-history\"){continue;}if(key.match(/(episode|show)/)||(as.title)?.match(/podcasts/i)){return null;}}"
},
"adsectionsoff": {
"version": {
"fr": "1.1.93",
"to": ""
},
"match": "((\"Carousel\".+?|onClickCarouselControls:.,spec:.[\\{\\}\\(\\)]{3,8})seeAllUri:(.),index.+?(UBIWrapper|id:.}\\)|\\.spec);)",
"replace": "$1 if ($3 && $3.match && $3.match(/(0JQ5DAnM3wGh0gz1MXnu3B|0JQ5DAnM3wGh0gz1MXnu3D|0JQ5IMCbQBLupUQrQFeCzx|0JQ5IMCbQBLqTJyy28YCa9|0JQ5IMCbQBLlC31GvtaB6w|0JQ5DAob0KOew1FBAMSmBz|0JQ5DAnM3wGh0gz1MXnu4w|0JQ5DAnM3wGh0gz1MXnu3C|0JQ5DAnM3wGh0gz1MXnu3s|0JQ5DAnM3wGh0gz1MXnu3M|0JQ5DAob0JCuWaGLU6ntFT|0JQ5DAnM3wGh0gz1MXnucG|0JQ5DAnM3wGh0gz1MXnu3E|0JQ5DAnM3wGh0gz1MXnu4h|0JQ5DAnM3wGh0gz1MXnu7R|0JQ5DAnM3wGh0gz1MXnu3w|0JQ5DAuChZYPe9iDhh2mJz|0JQ5DAnM3wGh0gz1MXnu3x|0JQ5DAob0JCuWaGLU6ntFY|0JQ5DAnM3wGh0gz1MXnu3u|0JQ5DAnM3wGh0gz1MXnu3q|0JQ5DAob0Jr9ClCbkV4pZD|0JQ5DAob0LaV9FOMJ9utY5)/)) {return null};"
},
"themelyrics": {
"theme": {
"default": {
Expand Down Expand Up @@ -1626,6 +1611,14 @@
"true$2"
]
},
"block_section": {
"version": {
"fr": "1.1.86",
"to": ""
},
"match": "(case 6:|const .=await .\\(.,.\\);)((return .\\.abrupt\\(\"|return[ \"],?)(null!=n&&|return\",)?(.)(\\);case 9|\\??.errors\\?Promise.reject.+?errors\\):.))",
"replace": "$1sectionBlock($5,\"{0}\");$2"
},
"banner_home": {
"version": {
"fr": "1.1.70",
Expand Down
Loading

0 comments on commit 1774024

Please sign in to comment.