diff --git a/src/config/i18n.js b/src/config/i18n.js
index 3601899..1837502 100644
--- a/src/config/i18n.js
+++ b/src/config/i18n.js
@@ -1874,6 +1874,11 @@ export const I18N = {
en: `Throttling translation interval (1-3600s)`,
zh_TW: `节流翻译间隔 (1-3600s)`,
},
+ show_origin_subtitle: {
+ zh: `显示原字幕`,
+ en: `Show original subtitles`,
+ zh_TW: `显示原字幕`,
+ },
};
export const newI18n = (lang) => (key) => I18N[key]?.[lang] || "";
diff --git a/src/subtitle/Menus.js b/src/subtitle/Menus.js
index ecef7dc..ea0a057 100644
--- a/src/subtitle/Menus.js
+++ b/src/subtitle/Menus.js
@@ -128,7 +128,7 @@ export function Menus({
return i18n("processing_subtitles");
}, [progressed, i18n]);
- const { isAISegment, skipAd, isBilingual } = formData;
+ const { isAISegment, skipAd, isBilingual, showOrigin } = formData;
return (
+
1) {
+ if (eventChunks.length > 1) {
const remainingChunks = eventChunks.slice(1);
this.#processRemainingChunksAsync({
chunks: remainingChunks,
- chunkCount,
videoId,
fromLang,
toLang,
segApiSetting,
});
- return [firstBatchSubtitles, 100 / eventChunks.length];
+ const processed = Math.floor(100 / eventChunks.length);
+
+ return [firstBatchSubtitles, processed];
} else {
return [firstBatchSubtitles, 100];
}
@@ -583,6 +606,10 @@ class YouTubeCaptionProvider {
return;
}
+ if (this.#setting.showOrigin) {
+ return;
+ }
+
if (!this.#subtitles.length) {
this.#showNotification(this.#i18n("waitting_for_subtitle"));
return;
@@ -605,8 +632,7 @@ class YouTubeCaptionProvider {
this.#showNotification(this.#i18n("subtitle_load_succeed"));
- const ytCaption = document.querySelector(YT_CAPTION_SELECT);
- ytCaption && (ytCaption.style.display = "none");
+ this.#hideYtCaption();
}
#destroyManager() {
@@ -619,6 +645,15 @@ class YouTubeCaptionProvider {
this.#managerInstance.destroy();
this.#managerInstance = null;
+ this.#showYtCaption();
+ }
+
+ #hideYtCaption() {
+ const ytCaption = document.querySelector(YT_CAPTION_SELECT);
+ ytCaption && (ytCaption.style.display = "none");
+ }
+
+ #showYtCaption() {
const ytCaption = document.querySelector(YT_CAPTION_SELECT);
ytCaption && (ytCaption.style.display = "block");
}
@@ -920,7 +955,6 @@ class YouTubeCaptionProvider {
async #processRemainingChunksAsync({
chunks,
- chunkCount,
videoId,
fromLang,
toLang,
@@ -968,7 +1002,7 @@ class YouTubeCaptionProvider {
}
if (subtitlesForThisChunk.length > 0) {
- const progressed = (chunkNum * 100) / chunkCount;
+ const progressed = Math.floor((chunkNum * 100) / (chunks.length + 1));
this.#subtitles.push(...subtitlesForThisChunk);
this.#progressed = progressed;