您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove all "[inhales]", "[loud noise]" from the subtitles
// ==UserScript== // @name Netflix subtitle cleanup // @namespace Violentmonkey Scripts // @match https://www.netflix.com/* // @grant none // @version 1.4 // @author Einar Lielmanis, [email protected] // @license MIT // @description Remove all "[inhales]", "[loud noise]" from the subtitles // ==/UserScript== let observed_node = undefined let kill_song_lyrics = false const cleanup = (t) => { if (kill_song_lyrics && t.includes('♪')) { return '' // ignore song lyrics } else if (t.includes('[') && t.includes(']')) { return t.replace(/(- *)?\[[^\]]+\]/g, '') // (maybe "- ") "[" .. (not "]")+ .. "]" } else if (t.includes('(') && t.includes(')')) { return t.replace(/(- *)?\([^\)]+\)/g, '') // (maybe "- ") "(" .. (not ")")+ .. ")" } return t } const on_mutated = (changes) => { const ts = observed_node.querySelectorAll('.player-timedtext-text-container span') for (let i = 0; i < ts.length; i++) { const t = ts[i].innerHTML const nt = cleanup(t) if (nt !== t) { ts[i].innerHTML = nt // console.log({ original: t, filtered: nt }) } } } const observer = new MutationObserver(on_mutated) const reobserve = () => { const elems = document.getElementsByClassName('player-timedtext') if (elems[0] !== undefined) { if (observed_node !== elems[0]) { observed_node = elems[0] console.log({ observed_node }) observer.observe(observed_node, { childList: true, subtree: true}) } } window.setTimeout(reobserve, 1000) } const run_tests = () => { // the tests are lightning fast, so just do run them quickly on every script startup const test_cleanup = (source, expected) => { console.assert(cleanup(source) === expected, { test_result: false, source, expected, actual: cleanup(source) }) } test_cleanup('normal text', 'normal text') test_cleanup('[coughs]', '') test_cleanup('[coughs] yeah', ' yeah') test_cleanup('-[coughs]', '') test_cleanup('- [coughs]', '') test_cleanup('- (inhales)', '') test_cleanup('some ♪ singing', '') console.log('tests ok') } console.log('Netflix subtitle filter userscript starting up') run_tests() reobserve()
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址