Skip to content

Commit

Permalink
🚧 Fix #50 bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
tolerious committed Sep 19, 2024
1 parent d6c81a1 commit b211d5b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/entryPoint/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ function processResponse(details) {
let data = [];

filter.ondata = (event) => {
let str = decoder.decode(event.data, { stream: true });
let str = decoder.decode(event.data);
data.push(str);
filter.write(encoder.encode(event.data));
};

filter.onstop = (event) => {
Expand All @@ -163,6 +162,9 @@ function processResponse(details) {
console.log(`Subtitles url: ${details.url}`);
notifyContentScript({ type: "youtube", url: details.url, data: json });
// 在这里处理 JSON 数据
data.forEach((d) => {
filter.write(encoder.encode(d));
});
} catch (e) {
alert("视频处理失败,请刷新页面重试");
}
Expand Down

0 comments on commit b211d5b

Please sign in to comment.