File tree Expand file tree Collapse file tree 2 files changed +0
-42
lines changed
Expand file tree Collapse file tree 2 files changed +0
-42
lines changed Original file line number Diff line number Diff line change 288288 background : # 555 ;
289289}
290290
291- .highlight-new-comment {
292- background-color : # ffff99 !important ;
293- animation : highlight-fade 3s ease;
294- }
295-
296- @keyframes highlight-fade {
297- from { background-color : # ffff99 ; }
298- to { background-color : inherit; }
299- }
Original file line number Diff line number Diff line change 196196 }
197197</ script >
198198
199- < script >
200- // Function to process and highlight new comments
201- function processComments ( ) {
202- const prevCommentIds = JSON . parse ( localStorage . getItem ( 'prevCommentIds' ) ) || [ ] ;
203- const currentCommentIds = [ ] ;
204- const comments = document . getElementsByClassName ( 'hcb-comment' ) ;
205-
206- Array . from ( comments ) . forEach ( comment => {
207- const id = comment . id ;
208- currentCommentIds . push ( id ) ;
209- if ( ! prevCommentIds . includes ( id ) ) {
210- comment . classList . add ( 'highlight-new-comment' ) ;
211- }
212- } ) ;
213-
214- localStorage . setItem ( 'prevCommentIds' , JSON . stringify ( currentCommentIds ) ) ;
215- }
216199
217- // Observe when comments are loaded dynamically
218- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
219- const commentBox = document . getElementById ( 'HCB_comment_box' ) ;
220- if ( ! commentBox ) return ;
221-
222- const observer = new MutationObserver ( ( mutations ) => {
223- const comments = commentBox . getElementsByClassName ( 'hcb-comment' ) ;
224- if ( comments . length > 0 ) {
225- observer . disconnect ( ) ; // Stop observing once comments are found
226- processComments ( ) ;
227- }
228- } ) ;
229-
230- observer . observe ( commentBox , { childList : true , subtree : true } ) ;
231- } ) ;
232- </ script >
233200</ body >
234201</ html >
You can’t perform that action at this time.
0 commit comments