Opening the offline redirection page if redirection failed 5 times #201

This commit is contained in:
ManeraKai 2022-04-18 08:06:05 +03:00
parent a1c652f6dd
commit 0c60dac4c6
1 changed files with 10 additions and 2 deletions

View File

@ -172,9 +172,17 @@ function redirectOfflineInstance(url, tabId) {
if (!newUrl) newUrl = spotifyHelper.switchInstance(url);
if (newUrl) browser.tabs.update(tabId, { url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}` });
if (newUrl) {
if (counter >= 5) {
browser.tabs.update(tabId, { url: `/pages/errors/instance_offline.html?url=${encodeURIComponent(newUrl)}` });
counter = 0;
} else {
browser.tabs.update(tabId, { url: newUrl });
counter++;
}
}
}
let counter = 0;
browser.webRequest.onResponseStarted.addListener(
details => {
if (!generalHelper.getAutoRedirect()) return null;