Skip to content

Instantly share code, notes, and snippets.

@to
Last active October 3, 2025 14:02
Show Gist options
  • Save to/f29579481a623feec94a55d7f086e1ee to your computer and use it in GitHub Desktop.
Save to/f29579481a623feec94a55d7f086e1ee to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Amazon - Copy Subtitle Text
// @description Amazon - Copy Subtitle Text.
// @version 0.2
// @author to
// @namespace https://github.com/to
// @license MIT
//
// @noframes
// @match https://www.amazon.co.jp/gp/video/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.co.jp
//
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// ==/UserScript==
let subs = [];
const getSub = () => {
const el = document.querySelector('.atvwebplayersdk-captions-text');
return el ?
el.innerHTML.replaceAll('<br>', ' ').replaceAll(/<.+?>/g, ' ').trim() : '';
};
setInterval(() => {
const t = getSub();
if (t && t !== subs[subs.length - 1])
subs.push(t);
}, 1000);
document.addEventListener('keydown', e => {
if (e.ctrlKey && e.shiftKey && e.code === 'KeyC') {
const t = getSub();
if (t) GM_setClipboard(t);
}
});
GM_registerMenuCommand('Copy subs', () => {
const n = +prompt('How many?');
if (n > 0) GM_setClipboard(subs.slice(-n).join('\n'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment