Created
February 17, 2019 02:51
-
-
Save kusaanko/f1ab3fe6d2b5aac763fadd9ed904910f to your computer and use it in GitHub Desktop.
Display subtitle while pressing S key in YouTube.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Key to Subtitles | |
// @namespace https://github.com/kusaanko | |
// @version 0.1 | |
// @description Display subtitle while pressing S key in YouTube. | |
// @author Kusaanko | |
// @match https://www.youtube.com/watch* | |
// @grant none | |
// @require https://code.jquery.com/jquery-3.3.1.min.js | |
// ==/UserScript== | |
(function() { | |
document.onkeydown = function(e) { | |
if(document.activeElement.nodeName!='INPUT'&&e.keyCode==83&&$('.ytp-subtitles-button.ytp-button').attr('aria-pressed')=='false') { | |
$('.ytp-subtitles-button.ytp-button').click(); | |
} | |
} | |
document.onkeyup = function(e) { | |
if(!document.activeElement.nodeName!='INPUT'&&e.keyCode==83&&$('.ytp-subtitles-button.ytp-button').attr('aria-pressed')=='true') { | |
$('.ytp-subtitles-button.ytp-button').click(); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment