From aa5a96fdb9b0b86c7362a4c3fe736a4fbf334a4c Mon Sep 17 00:00:00 2001 From: daniel k Date: Sat, 30 Dec 2023 22:32:58 +0900 Subject: [PATCH] fix embed video --- src/contentScript.js | 6 +++--- src/subtitle/videoHandler.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/contentScript.js b/src/contentScript.js index e3e06995..23d9fd56 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -48,7 +48,7 @@ $(async function initMouseTooltipTranslator() { return; } await detectPDF(); //check current page is pdf - checkYoutube(); + checkVideo(); checkGoogleDoc(); addElementEnv(); //add tooltip container applyStyleSetting(); //add tooltip style @@ -532,7 +532,7 @@ async function requestRecordTooltipText( async function getSetting() { setting = await util.loadSetting(function settingCallbackFn() { - checkYoutube(); + checkVideo(); applyStyleSetting(); selectedText = ""; ocrView.removeAllOcrEnv(); @@ -698,7 +698,7 @@ function checkGoogleDoc() { } // youtube================================ -async function checkYoutube() { +async function checkVideo() { if ( !matchUrl(document.location.href, "www.youtube.com") || setting["enableYoutube"] == "null" diff --git a/src/subtitle/videoHandler.js b/src/subtitle/videoHandler.js index ba86aca2..be74dbd7 100644 --- a/src/subtitle/videoHandler.js +++ b/src/subtitle/videoHandler.js @@ -317,7 +317,7 @@ async function getTranslatedSubtitle(baseUrl, lang) { function getUrlParam(url) { var vJson = {}; if (isShorts(url) || isEmbed(url)) { - vJson["v"] = url.match(/.*\/([^?]+)/)[1]; + vJson["v"] = new URL(url).pathname.split("/")[2]; } let params = new URL(url).searchParams;