freesir commited on
Commit
6ded595
·
verified ·
1 Parent(s): 0aacb5b

Delete script.js

Browse files
Files changed (1) hide show
  1. script.js +0 -30
script.js DELETED
@@ -1,30 +0,0 @@
1
- function generateSRT() {
2
- let srtContent = "";
3
- const subtitleElements = document.querySelectorAll("#subtitles div");
4
-
5
- // 遍历含时间戳的元素生成 SRT 格式内容
6
- subtitleElements.forEach((subtitle, index) => {
7
- const subtitleText = subtitle.textContent.trim();
8
-
9
- // 使用正则表达式匹配时间戳格式
10
- const timeMatch = subtitleText.match(/^(\d{2}:\d{2}:\d{2},\d{3} --> \d{2}:\d{2}:\d{2},\d{3})\s+(.*)$/);
11
- if (timeMatch) {
12
- const time = timeMatch[1];
13
- const text = timeMatch[2];
14
- srtContent += `${index + 1}\n${time}\n${text}\n\n`;
15
- }
16
- });
17
-
18
- // 创建 Blob 对象并生成下载链接
19
- const blob = new Blob([srtContent], { type: "text/srt" });
20
- const url = URL.createObjectURL(blob);
21
-
22
- // 创建下载链接
23
- const a = document.createElement("a");
24
- a.href = url;
25
- a.download = "subtitles.srt";
26
- a.click();
27
-
28
- // 释放 URL 对象
29
- URL.revokeObjectURL(url);
30
- }