Skip to content

Instantly share code, notes, and snippets.

@taowen
Last active February 4, 2024 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taowen/2a49387d5abc195ba57acbb94f4dd28f to your computer and use it in GitHub Desktop.
Save taowen/2a49387d5abc195ba57acbb94f4dd28f to your computer and use it in GitHub Desktop.
extract text from https://youtube.com
// ==UserScript==
// @name youtube转文本到剪贴板
// @description 方便粘贴到 chatgpt 进行问答
// @namespace github.com/taowen
// @match https://www.youtube.com/*
// @version 1.0.0
// @author taowen
// @license MIT
// @grant GM.registerMenuCommand
// @grant GM_setClipboard
// ==/UserScript==
GM.registerMenuCommand("复制转录文稿到剪贴板", () => {
const segments = [];
for(const elem of document.getElementsByClassName('segment-text')) {
segments.push(elem.textContent);
}
const text = segments.join(' ');
GM_setClipboard (text);
alert('copied ' + text.length + ' characters');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment