Advertisement
geraldandy

Remove YouTube Subtitle System Messages and Language Labels WORKS

Nov 27th, 2024
11
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Remove YouTube Subtitle System Messages and Language Labels WORKS
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Remove "click settings icon for settings" and "English" or "Auto-generated Thai" from YouTube captions, keeping only actual subtitles.
  6. // @author You
  7. // @match *://www.youtube.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14. // Function to remove unwanted captions
  15. function removeUnwantedCaptions() {
  16. const captions = document.querySelectorAll('.ytp-caption-segment');
  17. captions.forEach((caption) => {
  18. const text = caption.innerText.toLowerCase();
  19. // Remove language labels or the "click settings" message
  20. if (
  21. text === 'english' ||
  22. text === 'auto-generated thai' ||
  23. text.includes('auto-generated') ||
  24. text.includes('click') && text.includes('settings')
  25. ) {
  26. caption.style.display = 'none'; // Hide unwanted text
  27. }
  28. });
  29. }
  30.  
  31. // Observe changes to captions and clean up unwanted ones
  32. const observer = new MutationObserver(removeUnwantedCaptions);
  33. observer.observe(document.body, {
  34. childList: true,
  35. subtree: true,
  36. });
  37.  
  38. // Initial cleanup
  39. removeUnwantedCaptions();
  40. })();
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement