Netflix Subtitle Clipboard Auto-Copy

2/29/2024, 8:34:39 AM

ของเมื่อวันที่ 29-02-2024 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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        Netflix Subtitle Clipboard Auto-Copy
// @namespace   Violentmonkey Scripts
// @match       *://www.netflix.com/*
// @grant       GM_setClipboard
// @version     1.1
// @author      harrisonmg
// @description 2/29/2024, 8:34:39 AM
// @license     MIT
// ==/UserScript==
const copySubs = () => {
  for (const sub of document.querySelectorAll(".player-timedtext-text-container")) {
    const text = sub.innerText.replaceAll("\n", "");
    GM_setClipboard(text);
  }
}

const setup = () => {
  const sub_div = document.querySelector(".player-timedtext");
  if (sub_div === null) {
    setTimeout(setup, 250);
  } else {
    const observer = new MutationObserver(copySubs);
    const config = { attributes: true, childList: true, subtree: true };
    observer.observe(sub_div, config);
  }
}

setup();