Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Remove YouTube Subtitle System Messages and Language Labels WORKS
- // @namespace http://tampermonkey.net/
- // @version 1.2
- // @description Remove "click settings icon for settings" and "English" or "Auto-generated Thai" from YouTube captions, keeping only actual subtitles.
- // @author You
- // @match *://www.youtube.com/*
- // @grant none
- // ==/UserScript==
- (function () {
- 'use strict';
- // Function to remove unwanted captions
- function removeUnwantedCaptions() {
- const captions = document.querySelectorAll('.ytp-caption-segment');
- captions.forEach((caption) => {
- const text = caption.innerText.toLowerCase();
- // Remove language labels or the "click settings" message
- if (
- text === 'english' ||
- text === 'auto-generated thai' ||
- text.includes('auto-generated') ||
- text.includes('click') && text.includes('settings')
- ) {
- caption.style.display = 'none'; // Hide unwanted text
- }
- });
- }
- // Observe changes to captions and clean up unwanted ones
- const observer = new MutationObserver(removeUnwantedCaptions);
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
- // Initial cleanup
- removeUnwantedCaptions();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement