sonygod commited on
Commit
1c6e2dc
·
1 Parent(s): 955b15e
Files changed (1) hide show
  1. youtube_sub.js +7 -0
youtube_sub.js CHANGED
@@ -722,6 +722,11 @@ GM_addStyle(`
722
  return active[0].index;
723
  };
724
 
 
 
 
 
 
725
  const highlightWords = (currentTime, activeLine) => {
726
  if (!activeLine) return;
727
 
@@ -775,6 +780,8 @@ GM_addStyle(`
775
  rafId = requestAnimationFrame(() => handleTimeUpdate(video));
776
  return;
777
  }
 
 
778
 
779
  const lines = this.container.querySelectorAll('.subtitle-line');
780
  lines.forEach(line => {
 
722
  return active[0].index;
723
  };
724
 
725
+ const clearAllHighlights = () => {
726
+ const words = this.container.querySelectorAll('.subtitle-word.active');
727
+ words.forEach(word => word.classList.remove('active'));
728
+ };
729
+
730
  const highlightWords = (currentTime, activeLine) => {
731
  if (!activeLine) return;
732
 
 
780
  rafId = requestAnimationFrame(() => handleTimeUpdate(video));
781
  return;
782
  }
783
+ // Clear all highlights when switching lines
784
+ clearAllHighlights();
785
 
786
  const lines = this.container.querySelectorAll('.subtitle-line');
787
  lines.forEach(line => {