Skip to content

Commit 6b7eae0

Browse files
committed
[bugfix] 70 - some videos without time stamp, disappeared on hover
1 parent eb0f9f7 commit 6b7eae0

File tree

8 files changed

+355
-12
lines changed

8 files changed

+355
-12
lines changed

manifest-chrome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"manifest_version": 3,
3-
"version": "1.9.1",
3+
"version": "1.9.2",
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"icons": {

manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"manifest_version": 2,
3-
"version": "1.9.1",
3+
"version": "1.9.2",
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"icons": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"clean": "rm -r ./build",
1212

1313
"firefox-lint": "web-ext lint",
14-
"debug-android": "web-ext run -t firefox-android",
14+
"debug-android": "npm run prepare-firefox; web-ext run -t firefox-android --source-dir ./build/hys-f",
1515
"test": "jest"
1616
},
1717
"devDependencies": {

src/HidingShortsMore.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class HidingShortsWithContainer {
4141
hideShort(element) {
4242
// hide whole shelf if just contains "ytd-reel-item-renderer" tag. For now seems to be only used for yt-shorts videos
4343
// and hide any video container that contains a ref link to shorts
44-
if (element.querySelector('[href^="/shorts/"]') == null) return false;
44+
if (element.querySelector(SHORTS_HREF_SELECTOR) == null) return false;
4545
element.setAttribute("hidden", true);
4646

4747
hideContainerOfElement(this.container, element);
@@ -51,7 +51,7 @@ class HidingShortsWithContainer {
5151
showShort(element) {
5252
// hide whole shelf if just contains "ytd-reel-item-renderer" tag. For now seems to be only used for yt-shorts videos
5353
// and hide any video container that contains a ref link to shorts
54-
if (element.querySelector('[href^="/shorts/"]') == null) return;
54+
if (element.querySelector(SHORTS_HREF_SELECTOR) == null) return;
5555
if (element.hasAttribute("hidden")) {
5656
element.removeAttribute("hidden");
5757
showContainerOfElement(this.container, element);

src/main.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const DESKTOP_GUIDE_WRAPPER_MINI_SELECTOR = "ytd-mini-guide-renderer";
7777
const DESKTOP_NOTIFICATION_RENDERER = "ytd-notification-renderer";
7878

7979
const 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 */
8283
const SHELF_TAG_REGEX = /yt[dm]-reel-shelf-renderer/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

Comments
 (0)