YT Select Captions

Make YouTube captions selectable

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         YT Select Captions
// @namespace    https://greasyfork.org/users/901750-gooseob
// @version      1.1
// @description  Make YouTube captions selectable
// @author       GooseOb
// @license      MIT
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// ==/UserScript==

(() => {
  "use strict";

  var until = (getItem, check, timeout = 1e4, interval = 20) =>
    new Promise((res, rej) => {
      let item = getItem();
      if (check(item)) return res(item);
      const limit = timeout / interval;
      let i = 0;
      const id = setInterval(() => {
        item = getItem();
        if (check(item)) {
          clearInterval(id);
          res(item);
        } else if (++i > limit) {
          clearInterval(id);
          rej(new Error(`Timeout: item ${getItem.name} wasn't found`));
        }
      }, interval);
    });
  var untilAppear = (getItem, msToWait) => until(getItem, Boolean, msToWait);

  untilAppear(() =>
    document.getElementById("ytp-caption-window-container"),
  ).then((captionWindowCont) => {
    captionWindowCont.addEventListener(
      "mousedown",
      (e) => {
        e.stopPropagation();
      },
      { capture: true },
    );
  });

  var style = document.createElement("style");
  style.textContent = `
#ytp-caption-window-container {
  pointer-events: unset !important;
}
#ytp-caption-window-container > div {
  pointer-events: unset !important;
  user-select: text !important;
  -webkit-user-select: text !important;
}
.ytp-caption-segment {
	cursor: text !important;
}
`;
  document.head.appendChild(style);
})();