@@ -38,8 +38,9 @@ export default {
38
38
) ;
39
39
if ( ! label ) return ;
40
40
let text = numberFormat ( dislikeCount ) ;
41
- if ( label . textContent === text ) return ;
42
- label . textContent = text ;
41
+ if ( label . textContent !== text ) {
42
+ label . textContent = text ;
43
+ }
43
44
}
44
45
45
46
let videoId = getVideoId ( ) ;
@@ -62,9 +63,8 @@ export default {
62
63
if ( ! button ) return ;
63
64
64
65
function makeUI ( dislikeCount = 0 ) {
65
- // dislike text
66
66
let className = "yt-spec-button-shape-next__button-text-content" ;
67
- let exist = button . querySelector ( className ) ;
67
+ let exist = button . querySelector ( `. ${ className } ` ) ;
68
68
if ( exist ) {
69
69
exist . textContent = numberFormat ( dislikeCount ) ;
70
70
} else {
@@ -77,10 +77,7 @@ export default {
77
77
) ;
78
78
}
79
79
80
- // fix button style
81
80
button . style . width = "auto" ;
82
-
83
- // fix dislike icon style
84
81
const dislikeIcon = button . querySelector (
85
82
".yt-spec-button-shape-next__icon"
86
83
) ;
@@ -98,6 +95,7 @@ export default {
98
95
function run ( ) {
99
96
// remove all pre listeners
100
97
listeners . forEach ( ( fn ) => fn ?. ( ) ) ;
98
+ listeners = [ ] ; // Reset listeners array after clearing
101
99
102
100
if ( isShorts ( ) ) listeners . push ( listenShort ( ) ) ;
103
101
else listeners . push ( listenVideo ( ) ) ;
@@ -171,30 +169,27 @@ function isInViewport(element) {
171
169
const height = innerHeight || document . documentElement . clientHeight ;
172
170
const width = innerWidth || document . documentElement . clientWidth ;
173
171
return (
174
- // When short (channel) is ignored, the element (like/dislike AND short itself) is
175
- // hidden with a 0 DOMRect. In this case, consider it outside of Viewport
176
172
! ( rect . top == 0 && rect . left == 0 && rect . bottom == 0 && rect . right == 0 ) &&
177
173
rect . top >= 0 &&
178
174
rect . left >= 0 &&
179
175
rect . bottom <= height &&
180
176
rect . right <= width
181
177
) ;
182
178
}
179
+
183
180
function isVideoLoaded ( ) {
184
181
const videoId = getVideoId ( ) ;
185
182
return (
186
- // desktop: spring 2024 UI
187
183
document . querySelector ( `ytd-watch-grid[video-id='${ videoId } ']` ) !== null ||
188
- // desktop: older UI
189
184
document . querySelector ( `ytd-watch-flexy[video-id='${ videoId } ']` ) !== null ||
190
- // mobile: no video-id attribute
191
185
document . querySelector ( '#player[loading="false"]:not([hidden])' ) !== null
192
186
) ;
193
187
}
194
188
195
189
function isShorts ( ) {
196
190
return location . pathname . startsWith ( "/shorts" ) ;
197
191
}
192
+
198
193
function isNewDesign ( ) {
199
194
return document . getElementById ( "comment-teaser" ) !== null ;
200
195
}
0 commit comments