diff options
| author | ManeraKai <manerakai@protonmail.com> | 2022-04-18 08:06:05 +0300 |
|---|---|---|
| committer | ManeraKai <manerakai@protonmail.com> | 2022-04-18 08:06:33 +0300 |
| commit | 0c60dac4c65a0381646c3ebb18953a8474fa6111 (patch) | |
| tree | 7e54493a49a293626f89adf3d8b1405e77f489f3 | |
| parent | Merge branch 'master' of https://github.com/libredirect/libredirect (diff) | |
| download | libredirect-0c60dac4c65a0381646c3ebb18953a8474fa6111.zip | |
Opening the offline redirection page if redirection failed 5 times #201
| -rw-r--r-- | src/pages/background/background.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pages/background/background.js b/src/pages/background/background.js index 2aa361fc..fc9503ff 100644 --- a/src/pages/background/background.js +++ b/src/pages/background/background.js @@ -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; |
