@@ -77,6 +77,7 @@ const DESKTOP_GUIDE_WRAPPER_MINI_SELECTOR = "ytd-mini-guide-renderer";
7777const DESKTOP_NOTIFICATION_RENDERER = "ytd-notification-renderer" ;
7878
7979const SHORTS_TAB_SELECTOR = isMobile ? "ytm-pivot-bar-item-renderer>div[class='pivot-bar-item-tab pivot-shorts']" : "ytd-guide-entry-renderer>a:not([href])"
80+ const SHORTS_HREF_SELECTOR = `[href^="/shorts/"]` ;
8081
8182/* dedicated shelfs for shorts */
8283const SHELF_TAG_REGEX = / y t [ d m ] - r e e l - s h e l f - r e n d e r e r / gm
@@ -287,7 +288,7 @@ function setup() {
287288 ( mutationList , observer ) => {
288289 for ( const mutation of mutationList ) {
289290 if ( mutation . type === "childList" && mutation . target . tagName . toLowerCase ( ) == DESKTOP_NOTIFICATION_RENDERER ) {
290- if ( mutation . target . querySelector ( '[href^="/shorts/"]' ) != null )
291+ if ( mutation . target . querySelector ( SHORTS_HREF_SELECTOR ) != null )
291292 hideElement ( true , mutation . target )
292293 }
293294 }
@@ -300,7 +301,7 @@ function setup() {
300301 if ( popupContainer != null ) {
301302 const nRenderers = popupContainer . querySelectorAll ( DESKTOP_NOTIFICATION_RENDERER )
302303 nRenderers . forEach ( ( v ) => {
303- if ( v . querySelector ( '[href^="/shorts/"]' ) != null )
304+ if ( v . querySelector ( SHORTS_HREF_SELECTOR ) != null )
304305 hideElement ( hideYTShortsNotifications , v )
305306 } )
306307 }
@@ -421,7 +422,7 @@ function hideShorts(hide = true) {
421422 // and hide any video container that contains a ref link to shorts
422423 else if ( ( elementTagName . match ( SHELF_TAG_REGEX )
423424 && element . querySelector ( SHELF_ITEM_TAG_SELECTOR ) != null )
424- || element . querySelector ( '[href^="/shorts/"]' ) != null ) {
425+ || element . querySelector ( SHORTS_HREF_SELECTOR ) != null ) {
425426 hideElement ( hide , element , ( ) => { dRearrangeVideosInGrid . execute ( element ) } ) ;
426427 }
427428 else if ( hide ) {
@@ -448,9 +449,17 @@ function hideVideoIfOfType(types, element) {
448449 if ( types . includes ( "UPCOMING" ) ) {
449450 const foundElement = element . querySelector ( `badge-shape.yt-badge-shape--thumbnail-default:has(div.yt-badge-shape__text):not(:has(div.yt-badge-shape__icon))` )
450451 const foundElement2 = element . querySelector ( `toggle-button-view-model` ) // Notification button
451- const timeStatus = element . querySelector ( `badge-shape.yt-badge-shape--thumbnail-default>div.yt-badge-shape__text` )
452- if ( foundElement !== null && foundElement2 != null && timeStatus !== null && ! timeStatus . textContent . trim ( ) . match ( / ^ ( [ 0 - 9 ] : [ 0 - 9 ] | [ 0 - 9 ] ) + $ / ) )
452+ const timeStatuses = element . querySelectorAll ( `badge-shape.yt-badge-shape--thumbnail-default>div.yt-badge-shape__text` )
453+ let nonHaveTimeStatus = true
454+ timeStatuses . forEach ( timeStatus => {
455+ if ( timeStatus . textContent && timeStatus . textContent . trim ( ) . match ( / ^ ( [ 0 - 9 ] : [ 0 - 9 ] | [ 0 - 9 ] ) + $ / ) ) {
456+ nonHaveTimeStatus = false
457+ return
458+ }
459+ } )
460+ if ( foundElement !== null && foundElement2 !== null && timeStatuses . length > 0 && nonHaveTimeStatus ) {
453461 toHide = true
462+ }
454463 }
455464
456465 if ( ! toHide && types . includes ( "LIVE" ) ) {
0 commit comments