@@ -38,6 +38,8 @@ export default {
3838 ) ;
3939 if ( ! label ) return ;
4040 let text = numberFormat ( dislikeCount ) ;
41+ 42+ // Kiểm tra và chỉ cập nhật nếu cần thiết
4143 if ( label . textContent != text ) label . textContent = text ;
4244 }
4345
@@ -62,22 +64,31 @@ export default {
6264
6365 function makeUI ( dislikeCount = 0 ) {
6466 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
6670 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+ }
6878 } else {
6979 let dislikeText = document . createElement ( "div" ) ;
7080 dislikeText . classList . add ( className ) ;
7181 dislikeText . textContent = numberFormat ( dislikeCount ) ;
7282 button . appendChild ( dislikeText ) ;
83+ 7384 listeners . push (
7485 UfsGlobal . DOM . onElementRemoved ( dislikeText , ( ) =>
7586 makeUI ( dislikeCount )
7687 )
7788 ) ;
7889 }
7990
80- // fix button style
91+ // Sửa lại phong cách của nút
8192 button . style . width = "auto" ;
8293 const dislikeIcon = button . querySelector (
8394 ".yt-spec-button-shape-next__icon"
@@ -94,9 +105,9 @@ export default {
94105 }
95106
96107 function run ( ) {
97- // remove all pre listeners
108+ // Xóa tất cả listeners trước đó
98109 listeners . forEach ( ( fn ) => fn ?. ( ) ) ;
99- listeners = [ ] ; // Reset listeners array after clearing
110+ listeners = [ ] ; // Reset listeners array sau khi xóa
100111
101112 if ( isShorts ( ) ) listeners . push ( listenShort ( ) ) ;
102113 else listeners . push ( listenVideo ( ) ) ;
@@ -124,7 +135,6 @@ const cached = {};
124135
125136const getDislikeDataDebounced = UfsGlobal . Utils . debounce ( getDislikeData , 100 ) ;
126137
127- // Source code extracted from https://chrome.google.com/webstore/detail/return-youtube-dislike/gebbhagfogifgggkldgodflihgfeippi
128138async function getDislikeData ( videoId , callback ) {
129139 if ( ! videoId ) return ;
130140
0 commit comments