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

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

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

  1. // ==UserScript==
  2. // @name SubtitleEase: One-Click Video Subtitle Downloader
  3. // @name:zh-CN 字幕助手: 一键视频字幕下载器
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.3
  6. // @description Easily download subtitles from various video platforms with one click
  7. // @description:zh-CN 一键从多个视频平台轻松下载字幕
  8. // @author Your Name
  9. // @license MIT
  10. // @match *://*.youtube.com/*
  11. // @match *://*.viki.com/*
  12. // @match *://*.viu.com/*
  13. // @match *://*.kocowa.com/*
  14. // @match *://*.wetv.vip/*
  15. // @match *://*.bilibili.com/*
  16. // @match *://*.facebook.com/*
  17. // @match *://*.ted.com/*
  18. // @match *://*.altbalaji.com/*
  19. // @match *://*.brightcove.com/*
  20. // @match *://*.dailymotion.com/*
  21. // @match *://*.dimsum.my/*
  22. // @match *://*.ondemandchina.com/*
  23. // @match *://*.erosnow.com/*
  24. // @match *://*.drive.google.com/*
  25. // @match *://*.hotstar.com/*
  26. // @match *://*.iq.com/*
  27. // @match *://*.iflix.com/*
  28. // @match *://*.metopera.org/*
  29. // @match *://*.mgtv.com/*
  30. // @match *://*.ondemandkorea.com/*
  31. // @match *://*.tv.naver.com/*
  32. // @match *://*.tv.nrk.no/*
  33. // @match *://*.line.me/*
  34. // @match *://*.tubitv.com/*
  35. // @match *://*.vk.com/*
  36. // @match *://*.vlive.tv/*
  37. // @match *://*.vimeo.com/*
  38. // @match *://*.voot.com/*
  39. // @match *://*.weverse.io/*
  40. // @match *://*.zee5.com/*
  41. // @icon https://www.google.com/s2/favicons?sz=64&domain=downsub.com
  42. // @grant GM_registerMenuCommand
  43. // @grant GM_openInTab
  44. // @grant GM_addStyle
  45. // ==/UserScript==
  46.  
  47. (function() {
  48. 'use strict';
  49.  
  50. const DOWNSUB_URL = 'https://downsub.com/';
  51.  
  52. // 添加样式
  53. GM_addStyle(`
  54. .subtitle-ease-btn {
  55. position: fixed;
  56. bottom: 20px;
  57. right: 20px;
  58. background-color: #4CAF50;
  59. color: white;
  60. padding: 10px 20px;
  61. border: none;
  62. border-radius: 5px;
  63. cursor: pointer;
  64. z-index: 9999;
  65. }
  66. .subtitle-ease-btn:hover {
  67. background-color: #45a049;
  68. }
  69. `);
  70.  
  71. // 创建下载按钮
  72. function createDownloadButton() {
  73. const button = document.createElement('button');
  74. button.textContent = '下载字幕';
  75. button.className = 'subtitle-ease-btn';
  76. button.addEventListener('click', openDownSubTab);
  77. document.body.appendChild(button);
  78. }
  79.  
  80. // 打开 DownSub 标签页
  81. function openDownSubTab() {
  82. const currentURL = encodeURIComponent(window.location.href);
  83. const downsubURL = `${DOWNSUB_URL}?url=${currentURL}`;
  84. GM_openInTab(downsubURL, { active: true });
  85. }
  86.  
  87. // 注册菜单命令
  88. GM_registerMenuCommand("下载字幕", openDownSubTab);
  89.  
  90. // 创建下载按钮
  91. createDownloadButton();
  92.  
  93. // 监听 URL 变化(用于单页应用)
  94. let lastUrl = location.href;
  95. new MutationObserver(() => {
  96. const url = location.href;
  97. if (url !== lastUrl) {
  98. lastUrl = url;
  99. // 重新创建按钮,确保在页面切换后仍然存在
  100. const existingButton = document.querySelector('.subtitle-ease-btn');
  101. if (existingButton) {
  102. existingButton.remove();
  103. }
  104. createDownloadButton();
  105. }
  106. }).observe(document, { subtree: true, childList: true });
  107.  
  108. })();