-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
3 changed files
with
260 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.