Mac适用,YouTube字幕三指翻译。

只在Mac Safari 测试过,调用系统自带词典翻译,极简适用体验,内存占用少。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Mac适用,YouTube字幕三指翻译。
// @namespace    https://tampermonkey.net/
// @version      6.0
// @description  只在Mac Safari 测试过,调用系统自带词典翻译,极简适用体验,内存占用少。
// @author       雅典大学堂独立学者
// @match        https://www.youtube.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  /* 1. 等视频 ready 后注入覆盖样式 */
  function inject() {
    const style = document.createElement('style');
    style.id = 'yt-caption-fix';
    style.textContent = `
      /* 新版 Shadow-DOM 字幕行 */
      video + div > div > div > div > div,
      .ytp-caption-segment,
      .ytp-caption-window-container * {
        user-select: text !important;
        -webkit-user-select: text !important;
        cursor: text !important;
      }
    `;
    document.documentElement.appendChild(style);
  }

  /* 2. 启动:页面加载后执行一次即可 */
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', inject);
  } else {
    inject();
  }
})();