字幕助手: 一键视频字幕下载器

一键从多个视频平台轻松下载字幕

当前为 2024-09-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         SubtitleEase: One-Click Video Subtitle Downloader
// @name:zh-CN   字幕助手: 一键视频字幕下载器
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Easily download subtitles from various video platforms with one click
// @description:zh-CN 一键从多个视频平台轻松下载字幕
// @author       Your Name
// @license      MIT
// @match        *://*.youtube.com/*
// @match        *://*.viki.com/*
// @match        *://*.viu.com/*
// @match        *://*.kocowa.com/*
// @match        *://*.wetv.vip/*
// @match        *://*.bilibili.com/*
// @match        *://*.facebook.com/*
// @match        *://*.ted.com/*
// @match        *://*.altbalaji.com/*
// @match        *://*.brightcove.com/*
// @match        *://*.dailymotion.com/*
// @match        *://*.dimsum.my/*
// @match        *://*.ondemandchina.com/*
// @match        *://*.erosnow.com/*
// @match        *://*.drive.google.com/*
// @match        *://*.hotstar.com/*
// @match        *://*.iq.com/*
// @match        *://*.iflix.com/*
// @match        *://*.metopera.org/*
// @match        *://*.mgtv.com/*
// @match        *://*.ondemandkorea.com/*
// @match        *://*.tv.naver.com/*
// @match        *://*.tv.nrk.no/*
// @match        *://*.line.me/*
// @match        *://*.tubitv.com/*
// @match        *://*.vk.com/*
// @match        *://*.vlive.tv/*
// @match        *://*.vimeo.com/*
// @match        *://*.voot.com/*
// @match        *://*.weverse.io/*
// @match        *://*.zee5.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=downsub.com
// @grant        GM_registerMenuCommand
// @grant        GM_openInTab
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    const DOWNSUB_URL = 'https://downsub.com/';

    // 添加样式
    GM_addStyle(`
        .subtitle-ease-btn {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            z-index: 9999;
        }
        .subtitle-ease-btn:hover {
            background-color: #45a049;
        }
    `);


    // 打开 DownSub 标签页
    function openDownSubTab() {
        const currentURL = encodeURIComponent(window.location.href);
        const downsubURL = `${DOWNSUB_URL}?url=${currentURL}`;
        GM_openInTab(downsubURL, { active: true });
    }

    // 注册菜单命令
    GM_registerMenuCommand("下载字幕", openDownSubTab);

    // 监听 URL 变化(用于单页应用)
    let lastUrl = location.href;
    new MutationObserver(() => {
        const url = location.href;
        if (url !== lastUrl) {
            lastUrl = url;
            // 重新创建按钮,确保在页面切换后仍然存在
            const existingButton = document.querySelector('.subtitle-ease-btn');
            if (existingButton) {
                existingButton.remove();
            }
            createDownloadButton();
        }
    }).observe(document, { subtree: true, childList: true });

})();