// ==UserScript== // @name Youtube - Subtitle // @namespace https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs // @version 2 // @description Automatically enable the subtitles. // @author hacker09 // @match https://*.youtube.com/embed/* // @match https://www.youtube.com/watch?v=* // @icon https://www.youtube.com/s/desktop/03f86491/img/favicon.ico // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; var Counter = 0; //Create a new variable document.querySelector('video').addEventListener('play', function() { //When the video is played Counter += 1; //Increase the counter by 1 if (Counter === 1) //If it's the first time that the video is played { //Starts the if condition document.querySelector(".ytp-subtitles-button.ytp-button").innerHTML.match('unavailable') === null && document.querySelector(".ytp-subtitles-button.ytp-button").ariaPressed === 'false' ? document.querySelector(".ytp-subtitles-button.ytp-button").click() : ''; //Auto enable the subtitles if available and they are disabled } //Finishes the if condition }); //Finishes the timeupdate event listener })();