Netflix,方便Mac电脑快速选中翻译单词

Netflix,方便Mac电脑快速选中翻译单词(Mac触控板手势重按或三指轻点)

// ==UserScript==
// @name:en      Set Netflix caption selectable easy to quickly translate word for Mac
// @name         Netflix,方便Mac电脑快速选中翻译单词
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description:en  Set Netflix caption selectable, make it easy to quickly select and translate word in the caption for Mac
// @description  Netflix,方便Mac电脑快速选中翻译单词(Mac触控板手势重按或三指轻点)
// @author       jaywang
// @match        https://www.netflix.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
  'use strict';

  // Your code here...

  const mutationDiv = document.body;
  const observer = new MutationObserver(callback);
  observer.observe(mutationDiv, {
      childList: true, // 观察直接子节点
      subtree: true, // 及其更低的后代节点
      attributes: true,
      characterData: true
  });
  /** DOM变动的回调函数 */
  function callback (mutationRecord) {
      const mask = document.querySelector('.ltr-1420x7p');
      const subtitle = document.querySelector('.player-timedtext');
      if (mask) {
          mask.style.pointerEvents = 'none';
          // 顶部的按钮是可以选的
          const topBtns = mask.querySelectorAll('.medium.ltr-1dcjcj4');
          topBtns.forEach((el) => {
            el.style.pointerEvents = 'auto';
          })
      }
      if (subtitle) {
          subtitle.style.userSelect = 'text';
          subtitle.style.WebkitUserSelect = 'text';
      }
  }
})();