From 3ad9892f2a5adb88fc9ef316f8ec2eadac2f6ee9 Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Fri, 19 Jan 2024 14:52:17 +0400 Subject: [PATCH] Update index.js --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 9f146ff9..e8092f97 100644 --- a/src/index.js +++ b/src/index.js @@ -238,7 +238,7 @@ class VideoHandler { this.srcObserver.observe(this.video, { attributeFilter: ["src", "currentSrc"], }); - this.video.addEventListener("loadeddata", this.handleSrcChangedBound); + this.video.addEventListener("canplaythrough", this.handleSrcChanged); this.stopTranslationBound = this.stopTranslation.bind(this); this.handleVideoEventBound = this.handleVideoEvent.bind(this); this.changeOpacityOnEventBound = this.changeOpacityOnEvent.bind(this); @@ -1480,14 +1480,14 @@ class VideoHandler { videoData.translationHelp = null; // ! should be null for ALL websites except coursera and udemy ! videoData.isStream = false; // by default, we request the translation of the video - videoData.duration = this.video.duration; + videoData.duration = this.video.duration; // ! if 0 - we get 400 error videoData.videoId = getVideoId(this.site.host, this.video); videoData.detectedLanguage = this.translateFromLang; videoData.responseLanguage = this.translateToLang; if (!videoData.videoId) { this.ytData = {}; - return; + return videoData; } if (window.location.hostname.includes("youtube.com")) {