@@ -251,15 +251,29 @@ function mainScript(extensionId, SettingData, defaultSettings) {
251251
252252 const listeners = [ ] ;
253253
254- const canProceed = data => data ?. [ "contents" ]
255- || data ?. [ "videoDetails" ]
256- || data ?. [ "items" ]
257- || data ?. [ "onResponseReceivedActions" ]
258- || data ?. [ "onResponseReceivedEndpoints" ]
259- || data ?. [ "onResponseReceivedCommands" ] ;
254+ const canProceed = data => {
255+
256+ const endpoints = data ?. [ "onResponseReceivedEndpoints" ]
257+
258+ if ( endpoints != null && endpoints ?. constructor === Array && endpoints . length > 0 ) {
259+ for ( let i = endpoints . length - 1 ; i >= 0 ; i -- ) {
260+ if ( endpoints [ i ] ?. [ "reloadContinuationItemsCommand" ] ?. [ "targetId" ] === "comments-section" ) {
261+ return false
262+ }
263+ }
264+ }
265+
266+ return data ?. [ "contents" ]
267+ || data ?. [ "videoDetails" ]
268+ || data ?. [ "items" ]
269+ || data ?. [ "onResponseReceivedActions" ]
270+ || data ?. [ "onResponseReceivedEndpoints" ]
271+ || data ?. [ "onResponseReceivedCommands" ] ;
272+
273+ }
260274
261275 const override = function ( target , thisArg , argArray ) {
262- if ( ! argArray ?. [ 0 ] . url || Object . getOwnPropertyDescriptor ( argArray [ 0 ] , "url" ) !== undefined ) {
276+ if ( ! argArray ?. [ 0 ] ? .url || Object . getOwnPropertyDescriptor ( argArray [ 0 ] , "url" ) !== undefined ) {
263277 return target . apply ( thisArg , argArray ) ;
264278 } else {
265279 return target . apply ( thisArg , argArray ) . then ( response => {
@@ -590,7 +604,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
590604 return
591605 }
592606
593- const topBarButtons = Util . getSingleObjectByKey ( data , " topbarButtons") ;
607+ const topBarButtons = data ?. [ "topbar" ] ?. [ "desktopTopbarRenderer" ] ?. [ " topbarButtons"] ;
594608
595609 if ( ! topBarButtons ) {
596610 return ;
@@ -1930,6 +1944,24 @@ function mainScript(extensionId, SettingData, defaultSettings) {
19301944
19311945 } ;
19321946
1947+ const checkHomePageAds = itemContainer => {
1948+
1949+ for ( let i = itemContainer . length - 1 ; i >= 0 ; i -- ) {
1950+
1951+ const itemRenderer = itemContainer [ i ] ;
1952+ const exists = itemRenderer ?. [ "richItemRenderer" ] ?. [ "content" ] ?. [ "adSlotRenderer" ]
1953+ || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "statementBannerRenderer" ]
1954+ || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "brandVideoShelfRenderer" ]
1955+ || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "brandVideoSingletonRenderer" ] ;
1956+
1957+ if ( exists ) {
1958+ itemContainer . splice ( i , 1 ) ;
1959+ }
1960+
1961+ }
1962+
1963+ } ;
1964+
19331965 const listener = data => {
19341966
19351967 const subscribeButtonRenderer = Util . getSingleObjectByKey ( data , "subscribeButtonRenderer" ) ;
@@ -1955,7 +1987,6 @@ function mainScript(extensionId, SettingData, defaultSettings) {
19551987
19561988 // home page ads
19571989 const richGridRenderer = Util . getSingleObjectByKey ( data , "richGridRenderer" ) ;
1958- const appendContinuationItemsAction = Util . getSingleObjectByKey ( data , "appendContinuationItemsAction" ) ;
19591990
19601991 if ( ! isAdMastheadAllowed ) {
19611992
@@ -1976,20 +2007,23 @@ function mainScript(extensionId, SettingData, defaultSettings) {
19762007
19772008 if ( ! isAdHomeFeedAllowed ) {
19782009
1979- const itemContainer = richGridRenderer ?. [ "contents" ] || appendContinuationItemsAction ?. [ "continuationItems" ] ;
2010+ const itemContainer = richGridRenderer ?. [ "contents" ] ;
19802011
19812012 // home page list ads
19822013 if ( itemContainer ?. constructor === Array && itemContainer . length > 0 ) {
1983- for ( let i = itemContainer . length - 1 ; i >= 0 ; i -- ) {
2014+ checkHomePageAds ( itemContainer ) ;
2015+ }
19842016
1985- const itemRenderer = itemContainer [ i ] ;
1986- const exists = itemRenderer ?. [ "richItemRenderer" ] ?. [ "content" ] ?. [ "adSlotRenderer" ]
1987- || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "statementBannerRenderer" ]
1988- || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "brandVideoShelfRenderer" ]
1989- || itemRenderer ?. [ "richSectionRenderer" ] ?. [ "content" ] ?. [ "brandVideoSingletonRenderer" ] ;
2017+ const actions = data ?. [ "onResponseReceivedActions" ] ;
19902018
1991- if ( exists ) {
1992- itemContainer . splice ( i , 1 ) ;
2019+ // home page list continuation ads
2020+ if ( actions ?. constructor === Array && actions . length > 0 ) {
2021+ for ( let i = actions . length - 1 ; i >= 0 ; i -- ) {
2022+
2023+ const continuationItems = actions [ i ] ?. [ "appendContinuationItemsAction" ] ?. [ "continuationItems" ] ;
2024+
2025+ if ( continuationItems ?. constructor === Array && continuationItems . length > 0 ) {
2026+ checkHomePageAds ( continuationItems ) ;
19932027 }
19942028
19952029 }
@@ -2580,9 +2614,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
25802614 if ( richGridPages . indexOf ( window . location . pathname ) > - 1 ) {
25812615
25822616 const richGridRenderer = Util . getSingleObjectByKey ( data , "richGridRenderer" ) ;
2583- const appendContinuationItemsAction = Util . getSingleObjectByKey ( data , "appendContinuationItemsAction" ) ;
2584- const itemContainer = richGridRenderer ?. [ "contents" ]
2585- || appendContinuationItemsAction ?. [ "continuationItems" ] ;
2617+ const itemContainer = richGridRenderer ?. [ "contents" ] ;
25862618
25872619 if ( itemContainer ?. constructor === Array && itemContainer . length > 0 ) {
25882620
@@ -2643,9 +2675,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26432675 } else if ( Util . isWatchPage ( ) ) {
26442676
26452677 const secondaryResults = Util . getSingleObjectByKey ( data , "secondaryResults" ) ;
2646- const appendContinuationItemsAction = Util . getSingleObjectByKey ( data , "appendContinuationItemsAction" ) ;
2647- const itemContainer = secondaryResults ?. [ "secondaryResults" ] ?. [ "results" ]
2648- || appendContinuationItemsAction ?. [ "continuationItems" ] ;
2678+ const itemContainer = secondaryResults ?. [ "secondaryResults" ] ?. [ "results" ] ;
26492679
26502680 if ( itemContainer ?. constructor === Array && itemContainer . length > 0 ) {
26512681
@@ -2696,9 +2726,7 @@ function mainScript(extensionId, SettingData, defaultSettings) {
26962726 } else if ( sectionListPages . indexOf ( window . location . pathname ) > - 1 ) {
26972727
26982728 const sectionListRenderer = Util . getSingleObjectByKey ( data , "sectionListRenderer" ) ;
2699- const appendContinuationItemsAction = Util . getSingleObjectByKey ( data , "appendContinuationItemsAction" ) ;
2700- const itemContainer = sectionListRenderer ?. [ "contents" ]
2701- || appendContinuationItemsAction ?. [ "continuationItems" ] ;
2729+ const itemContainer = sectionListRenderer ?. [ "contents" ] ;
27022730
27032731 if ( itemContainer ?. constructor === Array && itemContainer . length > 0 ) {
27042732
0 commit comments