@@ -38,6 +38,8 @@ export default {
38
38
) ;
39
39
if ( ! label ) return ;
40
40
let text = numberFormat ( dislikeCount ) ;
41
+
42
+ // Kiểm tra và chỉ cập nhật nếu cần thiết
41
43
if ( label . textContent != text ) label . textContent = text ;
42
44
}
43
45
@@ -62,22 +64,31 @@ export default {
62
64
63
65
function makeUI ( dislikeCount = 0 ) {
64
66
let className = "yt-spec-button-shape-next__button-text-content" ;
65
- let exist = button . querySelector ( className ) ;
67
+ let exist = button . querySelector ( `.${ className } ` ) ;
68
+
69
+ // Kiểm tra nếu phần tử đã tồn tại, chỉ cập nhật nội dung
66
70
if ( exist ) {
67
- exist . textContent = numberFormat ( dislikeCount ) ;
71
+ const currentText = exist . textContent ;
72
+ const newText = numberFormat ( dislikeCount ) ;
73
+
74
+ // Chỉ cập nhật nếu nội dung thay đổi
75
+ if ( currentText !== newText ) {
76
+ exist . textContent = newText ;
77
+ }
68
78
} else {
69
79
let dislikeText = document . createElement ( "div" ) ;
70
80
dislikeText . classList . add ( className ) ;
71
81
dislikeText . textContent = numberFormat ( dislikeCount ) ;
72
82
button . appendChild ( dislikeText ) ;
83
+
73
84
listeners . push (
74
85
UfsGlobal . DOM . onElementRemoved ( dislikeText , ( ) =>
75
86
makeUI ( dislikeCount )
76
87
)
77
88
) ;
78
89
}
79
90
80
- // fix button style
91
+ // Sửa lại phong cách của nút
81
92
button . style . width = "auto" ;
82
93
const dislikeIcon = button . querySelector (
83
94
".yt-spec-button-shape-next__icon"
@@ -94,9 +105,9 @@ export default {
94
105
}
95
106
96
107
function run ( ) {
97
- // remove all pre listeners
108
+ // Xóa tất cả listeners trước đó
98
109
listeners . forEach ( ( fn ) => fn ?. ( ) ) ;
99
- listeners = [ ] ; // Reset listeners array after clearing
110
+ listeners = [ ] ; // Reset listeners array sau khi xóa
100
111
101
112
if ( isShorts ( ) ) listeners . push ( listenShort ( ) ) ;
102
113
else listeners . push ( listenVideo ( ) ) ;
@@ -124,7 +135,6 @@ const cached = {};
124
135
125
136
const getDislikeDataDebounced = UfsGlobal . Utils . debounce ( getDislikeData , 100 ) ;
126
137
127
- // Source code extracted from https://chrome.google.com/webstore/detail/return-youtube-dislike/gebbhagfogifgggkldgodflihgfeippi
128
138
async function getDislikeData ( videoId , callback ) {
129
139
if ( ! videoId ) return ;
130
140
0 commit comments