Forked from qwertyuiop6/TranslateToChineseOnYouTube.user.js
Created
October 23, 2019 06:37
-
-
Save insta-form/1f0b6adb18a50234543d95ad3bb867bd to your computer and use it in GitHub Desktop.
Translate to Chinese automatically. 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 自动翻译->字幕中文简体 | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description translate to Chinese automatically. | |
| // @author qwertyuiop6 | |
| // @match https://www.youtube.com/watch* | |
| // @require https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function translateToChinese(){ | |
| var sub = $('[role="menuitem"]:contains("字幕")'); | |
| if(!sub.length) return; | |
| sub.click(); | |
| var subc = $('[role="menuitemradio"]:contains("中文(简体)")'); | |
| if (subc.length) { | |
| subc.click(); | |
| } else { | |
| var autoTrans = $('[role="menuitemradio"]:contains("自动翻译")'); | |
| if (!autoTrans.length) return; | |
| autoTrans.click(); | |
| var autoTransC = $('[role="menuitemradio"]:contains("中文(简体)")'); | |
| if (!autoTransC.length) return; | |
| autoTransC.click(); | |
| } | |
| } | |
| function onLoadStart(){ | |
| $('.ytp-subtitles-button[aria-pressed="false"]').click(); | |
| $('.ytp-settings-button').click(); | |
| translateToChinese(); | |
| $('.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