Skip to content

Commit 492e4df

Browse files
committed
[bugfix] upcoming video should not have a time in badge's text field;
1 parent a7ecb71 commit 492e4df

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
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.8.7",
3+
"version": "1.8.8",
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.8.7",
3+
"version": "1.8.8",
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"icons": {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"scripts": {
33
"test": "jest",
4-
"zip-firefox": "cp manifest-firefox.json manifest.json; zip hide-youtube-shorts-firefox.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
5-
"zip-chrome": "cp manifest-chrome.json manifest.json; zip hide-youtube-shorts-chrome.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
4+
"zip-firefox": "cp manifest-firefox.json manifest.json; zip -r hide-youtube-shorts-firefox.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
5+
"zip-chrome": "cp manifest-chrome.json manifest.json; zip -r hide-youtube-shorts-chrome.zip _locales/* icons/* src/* manifest.json LICENCE.md Readme.md; rm manifest.json",
66
"zip": "npm run zip-firefox; npm run zip-chrome;"
77
},
88
"devDependencies": {

src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,8 @@ function hideVideoIfOfType(types, element) {
448448
if (types.includes("UPCOMING")) {
449449
const foundElement = element.querySelector(`badge-shape.yt-badge-shape--thumbnail-default:has(div.yt-badge-shape__text):not(:has(div.yt-badge-shape__icon))`)
450450
const foundElement2 = element.querySelector(`toggle-button-view-model`) // Notification button
451-
if (foundElement !== null && foundElement2 != null)
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])+$/))
452453
toHide = true
453454
}
454455

tests/main.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ function hideVideoIfOfType(types, element) {
2222
if (types.includes("UPCOMING")) {
2323
const foundElement = element.querySelector(`badge-shape.yt-badge-shape--thumbnail-default:has(div.yt-badge-shape__text):not(:has(div.yt-badge-shape__icon))`)
2424
const foundElement2 = element.querySelector(`toggle-button-view-model`) // Notification button
25-
if (foundElement !== null && foundElement2 != null)
25+
const timeStatus = element.querySelector(`badge-shape.yt-badge-shape--thumbnail-default>div.yt-badge-shape__text`)
26+
if (foundElement !== null && foundElement2 != null && timeStatus !== null && !timeStatus.textContent.trim().match(/^([0-9]:[0-9]|[0-9])+$/)) {
2627
toHide = true
28+
}
2729
}
2830

2931
if (!toHide && types.includes("LIVE")) {

0 commit comments

Comments
 (0)