Skip to content

Commit

Permalink
Фиксы
Browse files Browse the repository at this point in the history
Надеюсь сейчас проблема исчезнет
  • Loading branch information
SashaXser authored Jul 30, 2023
1 parent 38cfa2f commit bfbb0dd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion dist/vot-cloudflare-min.user.js

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions dist/vot-cloudflare.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2747,7 +2747,8 @@ async function src_main() {
.querySelector("#VOTTranslateFromLang")
.addEventListener("change", async (event) => {
debug/* default */.Z.log("[onchange] select from language", event.target.value);
await setDetectedLangauge(videoData, event.target.value);
if (videoData.author !== "")
await setDetectedLangauge(videoData, event.target.value);
});

menuOptions
Expand Down Expand Up @@ -2986,11 +2987,11 @@ async function src_main() {
async function setDetectedLangauge(data, videolang) {
data.detectedLanguage = videolang;
data.responseLanguage = lang;
if (!Object.keys(constants/* availableLangs */.tW).includes(videolang) && data.author !== "") {
return setDetectedLangauge(data, "en");
if (!Object.keys(constants/* availableLangs */.tW).includes(videolang)) {
return setDetectedLangauge(data, "en");
}

if (data.author !== "") await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);
await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);

return data;
}
Expand Down Expand Up @@ -3072,7 +3073,8 @@ async function src_main() {

if (window.location.hostname.includes("youtube.com")) {
ytData = await getYTVideoData();
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
if (ytData.author !== "")
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
videoData.detectedLanguage = ytData.detectedLanguage;
videoData.responseLanguage = ytData.responseLanguage;
} else if (
Expand Down Expand Up @@ -3317,6 +3319,7 @@ async function src_main() {
}

const translateExecutor = async (VIDEO_ID) => {
if (!videoData.detectedLanguage) return;
debug/* default */.Z.log("Run videoValidator");
await videoValidator();
debug/* default */.Z.log("Run translateFunc");
Expand Down Expand Up @@ -3476,7 +3479,6 @@ async function src_main() {
);
}


document.addEventListener("click", async (event) => {
const block = document.querySelector(".translationBlock");
const menuContainer = document.querySelector(".translationMenuContent");
Expand Down Expand Up @@ -3675,7 +3677,7 @@ async function src_main() {
}
const ytPageLeave = async () => {
document.body.dispatchEvent(new Event("yt-translate-stop"));
};
};
document.addEventListener("spfdone", ytPageLeave);
document.addEventListener("yt-navigate-finish", ytPageLeave);
document.addEventListener("spfrequest", ytPageLeave);
Expand Down Expand Up @@ -3908,6 +3910,7 @@ async function src_main() {
src_main().catch((e) => {
console.error(e);
});

})();

/******/ })()
Expand Down
2 changes: 1 addition & 1 deletion dist/vot-min.user.js

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions dist/vot.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2695,7 +2695,8 @@ async function src_main() {
.querySelector("#VOTTranslateFromLang")
.addEventListener("change", async (event) => {
utils_debug.log("[onchange] select from language", event.target.value);
await setDetectedLangauge(videoData, event.target.value);
if (videoData.author !== "")
await setDetectedLangauge(videoData, event.target.value);
});

menuOptions
Expand Down Expand Up @@ -2915,11 +2916,11 @@ async function src_main() {
async function setDetectedLangauge(data, videolang) {
data.detectedLanguage = videolang;
data.responseLanguage = lang;
if (!Object.keys(availableLangs).includes(videolang) && data.author !== "") {
return setDetectedLangauge(data, "en");
if (!Object.keys(availableLangs).includes(videolang)) {
return setDetectedLangauge(data, "en");
}

if (data.author !== "") await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);
await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);

return data;
}
Expand Down Expand Up @@ -3001,7 +3002,8 @@ async function src_main() {

if (window.location.hostname.includes("youtube.com")) {
ytData = await getYTVideoData();
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
if (ytData.author !== "")
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
videoData.detectedLanguage = ytData.detectedLanguage;
videoData.responseLanguage = ytData.responseLanguage;
} else if (
Expand Down Expand Up @@ -3246,6 +3248,7 @@ async function src_main() {
}

const translateExecutor = async (VIDEO_ID) => {
if (!videoData.detectedLanguage) return;
utils_debug.log("Run videoValidator");
await videoValidator();
utils_debug.log("Run translateFunc");
Expand Down Expand Up @@ -3395,7 +3398,6 @@ async function src_main() {
);
}


document.addEventListener("click", async (event) => {
const block = document.querySelector(".translationBlock");
const menuContainer = document.querySelector(".translationMenuContent");
Expand Down Expand Up @@ -3594,7 +3596,7 @@ async function src_main() {
}
const ytPageLeave = async () => {
document.body.dispatchEvent(new Event("yt-translate-stop"));
};
};
document.addEventListener("spfdone", ytPageLeave);
document.addEventListener("yt-navigate-finish", ytPageLeave);
document.addEventListener("spfrequest", ytPageLeave);
Expand Down Expand Up @@ -3827,6 +3829,7 @@ async function src_main() {
src_main().catch((e) => {
console.error(e);
});

})();

/******/ })()
Expand Down
15 changes: 7 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ async function main() {
.querySelector("#VOTTranslateFromLang")
.addEventListener("change", async (event) => {
debug.log("[onchange] select from language", event.target.value);
await setDetectedLangauge(videoData, event.target.value);
if (videoData.author !== "")
await setDetectedLangauge(videoData, event.target.value);
});

menuOptions
Expand Down Expand Up @@ -543,15 +544,11 @@ async function main() {
async function setDetectedLangauge(data, videolang) {
data.detectedLanguage = videolang;
data.responseLanguage = lang;
if (
!Object.keys(availableLangs).includes(videolang) &&
data.author !== ""
) {
if (!Object.keys(availableLangs).includes(videolang)) {
return setDetectedLangauge(data, "en");
}

if (data.author !== "")
await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);
await setSelectMenuValues(data.detectedLanguage, data.responseLanguage);

return data;
}
Expand Down Expand Up @@ -633,7 +630,8 @@ async function main() {

if (window.location.hostname.includes("youtube.com")) {
ytData = await getYTVideoData();
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
if (ytData.author !== "")
ytData = await setDetectedLangauge(ytData, ytData.detectedLanguage);
videoData.detectedLanguage = ytData.detectedLanguage;
videoData.responseLanguage = ytData.responseLanguage;
} else if (
Expand Down Expand Up @@ -878,6 +876,7 @@ async function main() {
}

const translateExecutor = async (VIDEO_ID) => {
if (!videoData.detectedLanguage) return;
debug.log("Run videoValidator");
await videoValidator();
debug.log("Run translateFunc");
Expand Down

0 comments on commit bfbb0dd

Please sign in to comment.