Skip to content

Commit

Permalink
Изменение проверки недоступности сервера Яндекса
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaXser committed Nov 25, 2024
1 parent 1833d1b commit 43893e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/headers.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"deno.dev",
"onrender.com",
"workers.dev",
"speed.cloudflare.com",
"porntn.com"
]
}
35 changes: 19 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,25 @@ class VideoHandler {
);
}

let countryCode;
try {
const countryResponse = await GM_fetch(
"https://speed.cloudflare.com/meta",
{
timeout: 5000,
},
);
const { country } = await countryResponse.json();
countryCode = country;
} catch (err) {
console.error("[VOT] Error getting country:", err);
}

if (
!this.data.translateProxyEnabled &&
GM_info?.scriptHandler &&
proxyOnlyExtensions.includes(GM_info.scriptHandler)
countryCode === "UA" ||
(!this.data.translateProxyEnabled &&
GM_info?.scriptHandler &&
proxyOnlyExtensions.includes(GM_info.scriptHandler))
) {
this.data.translateProxyEnabled = 1;
await votStorage.set("translateProxyEnabled", 1);
Expand Down Expand Up @@ -2039,19 +2054,7 @@ class VideoHandler {
return;
}

try {
this.subtitlesList = await getSubtitles(this.votClient, this.videoData);
} catch (err) {
debug.log("Error with yandex server, try auto-fix...", err);
this.votOpts = {
fetchFn: GM_fetch,
hostVOT: votBackendUrl,
host: this.data.proxyWorkerHost,
};
this.votClient = new VOTWorkerClient(this.votOpts);
this.subtitlesList = await getSubtitles(this.votClient, this.videoData);
await votStorage.set("translateProxyEnabled", 1);
}
this.subtitlesList = await getSubtitles(this.votClient, this.videoData);

if (!this.subtitlesList) {
await this.changeSubtitlesLang("disabled");
Expand Down

0 comments on commit 43893e8

Please sign in to comment.