YT Select Captions

Make YouTube captions selectable

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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);
})();