Skip to content

Commit 3d53156

Browse files
committed
Closes #971
1 parent 089aaa2 commit 3d53156

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

src/chrome/js/background-inject.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,15 +2502,22 @@ function mainScript(extensionId, SettingData, defaultSettings) {
25022502
"ytd-grid-video-renderer",
25032503
"ytd-compact-video-renderer"
25042504
];
2505+
const richGridPages = [
2506+
"/",
2507+
"/podcasts",
2508+
];
2509+
const sectionListPages = [
2510+
"/results",
2511+
"/feed/trending",
2512+
"/gaming",
2513+
];
25052514
const removeItems = data => {
25062515

25072516
if (!data) {
25082517
return;
25092518
}
25102519

2511-
if (window.location.pathname === "/") {
2512-
2513-
// home page
2520+
if (richGridPages.indexOf(window.location.pathname) > -1) {
25142521

25152522
const richGridRenderer = Util.getSingleObjectByKey(data, "richGridRenderer");
25162523
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
@@ -2575,8 +2582,6 @@ function mainScript(extensionId, SettingData, defaultSettings) {
25752582

25762583
} else if (Util.isWatchPage()) {
25772584

2578-
// watch page
2579-
25802585
const secondaryResults = Util.getSingleObjectByKey(data, "secondaryResults");
25812586
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
25822587
const itemContainer = secondaryResults?.["secondaryResults"]?.["results"]
@@ -2603,9 +2608,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26032608

26042609
}
26052610

2606-
} else if (window.location.pathname === "/results") {
2607-
2608-
// search page
2611+
} else if (sectionListPages.indexOf(window.location.pathname) > -1) {
26092612

26102613
const sectionListRenderer = Util.getSingleObjectByKey(data, "sectionListRenderer");
26112614
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
@@ -2637,11 +2640,9 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26372640
items.splice(j, 1);
26382641
}
26392642

2640-
const shelfItems = items[j]
2641-
?.["shelfRenderer"]
2642-
?.["content"]
2643-
?.["verticalListRenderer"]
2644-
?.["items"];
2643+
const shelfRendererContent = items[j]?.["shelfRenderer"]?.["content"];
2644+
const shelfItems = shelfRendererContent?.["verticalListRenderer"]?.["items"]
2645+
|| shelfRendererContent?.["expandedShelfContentsRenderer"]?.["items"];
26452646

26462647
if (shelfItems?.constructor === Array && shelfItems.length > 0) {
26472648

@@ -2724,7 +2725,9 @@ function mainScript(extensionId, SettingData, defaultSettings) {
27242725

27252726
return {
27262727
targetTags: targetTags,
2727-
update: update
2728+
update: update,
2729+
allowedRichGridPages: richGridPages,
2730+
allowedSectionListPages: sectionListPages,
27282731
};
27292732

27302733
})();
@@ -2774,7 +2777,8 @@ function mainScript(extensionId, SettingData, defaultSettings) {
27742777

27752778
if (window.location.pathname !== "/"
27762779
&& !Util.isWatchPage()
2777-
&& window.location.pathname !== "/results"
2780+
&& FeatureBlacklist.allowedRichGridPages.indexOf(window.location.pathname) < 0
2781+
&& FeatureBlacklist.allowedSectionListPages.indexOf(window.location.pathname) < 0
27782782
) {
27792783
return;
27802784
}

src/firefox/js/background-inject.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,15 +2502,22 @@ function mainScript(extensionId, SettingData, defaultSettings) {
25022502
"ytd-grid-video-renderer",
25032503
"ytd-compact-video-renderer"
25042504
];
2505+
const richGridPages = [
2506+
"/",
2507+
"/podcasts",
2508+
];
2509+
const sectionListPages = [
2510+
"/results",
2511+
"/feed/trending",
2512+
"/gaming",
2513+
];
25052514
const removeItems = data => {
25062515

25072516
if (!data) {
25082517
return;
25092518
}
25102519

2511-
if (window.location.pathname === "/") {
2512-
2513-
// home page
2520+
if (richGridPages.indexOf(window.location.pathname) > -1) {
25142521

25152522
const richGridRenderer = Util.getSingleObjectByKey(data, "richGridRenderer");
25162523
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
@@ -2575,8 +2582,6 @@ function mainScript(extensionId, SettingData, defaultSettings) {
25752582

25762583
} else if (Util.isWatchPage()) {
25772584

2578-
// watch page
2579-
25802585
const secondaryResults = Util.getSingleObjectByKey(data, "secondaryResults");
25812586
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
25822587
const itemContainer = secondaryResults?.["secondaryResults"]?.["results"]
@@ -2603,9 +2608,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26032608

26042609
}
26052610

2606-
} else if (window.location.pathname === "/results") {
2607-
2608-
// search page
2611+
} else if (sectionListPages.indexOf(window.location.pathname) > -1) {
26092612

26102613
const sectionListRenderer = Util.getSingleObjectByKey(data, "sectionListRenderer");
26112614
const appendContinuationItemsAction = Util.getSingleObjectByKey(data, "appendContinuationItemsAction");
@@ -2637,11 +2640,9 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26372640
items.splice(j, 1);
26382641
}
26392642

2640-
const shelfItems = items[j]
2641-
?.["shelfRenderer"]
2642-
?.["content"]
2643-
?.["verticalListRenderer"]
2644-
?.["items"];
2643+
const shelfRendererContent = items[j]?.["shelfRenderer"]?.["content"];
2644+
const shelfItems = shelfRendererContent?.["verticalListRenderer"]?.["items"]
2645+
|| shelfRendererContent?.["expandedShelfContentsRenderer"]?.["items"];
26452646

26462647
if (shelfItems?.constructor === Array && shelfItems.length > 0) {
26472648

@@ -2724,7 +2725,9 @@ function mainScript(extensionId, SettingData, defaultSettings) {
27242725

27252726
return {
27262727
targetTags: targetTags,
2727-
update: update
2728+
update: update,
2729+
allowedRichGridPages: richGridPages,
2730+
allowedSectionListPages: sectionListPages,
27282731
};
27292732

27302733
})();
@@ -2774,7 +2777,8 @@ function mainScript(extensionId, SettingData, defaultSettings) {
27742777

27752778
if (window.location.pathname !== "/"
27762779
&& !Util.isWatchPage()
2777-
&& window.location.pathname !== "/results"
2780+
&& FeatureBlacklist.allowedRichGridPages.indexOf(window.location.pathname) < 0
2781+
&& FeatureBlacklist.allowedSectionListPages.indexOf(window.location.pathname) < 0
27782782
) {
27792783
return;
27802784
}

0 commit comments

Comments
 (0)