Last active
September 15, 2018 15:26
-
-
Save GitHub30/6e2cfc8245b4780dfa1b2355f3663e7b to your computer and use it in GitHub Desktop.
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 YouTube Watch | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description translate to Japanease automatically. | |
| // @author John Doe | |
| // @match https://www.youtube.com/watch* | |
| // @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js | |
| // @downloadURL https://gist.github.com/GitHub30/6e2cfc8245b4780dfa1b2355f3663e7b/raw/bdae666e5a11127d24b91770e01435978de81973/TranslateToJapaneseOnYouTube.user.js | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function translateToJapanese(){ | |
| var 字幕 = $('[role="menuitem"]:contains("字幕")'); | |
| if(!字幕.length) return; | |
| 字幕.click(); | |
| var 日本語 = $('[role="menuitemradio"]:contains("日本語")'); | |
| if (日本語.length) { | |
| 日本語.click(); | |
| } else { | |
| var 自動翻訳 = $('[role="menuitemradio"]:contains("自動翻訳")'); | |
| if (!自動翻訳.length) return; | |
| 自動翻訳.click(); | |
| var 自動翻訳日本語 = $('[role="menuitemradio"]:contains("日本語")'); | |
| if (!自動翻訳日本語.length) return; | |
| 自動翻訳日本語.click(); | |
| } | |
| } | |
| function onLoadStart(){ | |
| $('.ytp-subtitles-button[aria-pressed="false"]').click(); | |
| $('.ytp-settings-button').click(); | |
| translateToJapanese(); | |
| $('.ytp-settings-button').click(); | |
| } | |
| $('video').on('loadstart', onLoadStart).trigger('loadstart'); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment