From 146dc68d5cb45befbe96572bd419298c00848f53 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 17 Feb 2021 13:28:38 +0100 Subject: [PATCH] Use CORS request for suspended check --- index.html | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 6ed19399f..bc8a40ef1 100644 --- a/index.html +++ b/index.html @@ -177,13 +177,14 @@ } async function isUp (url) { - try { - await fetchTimeout(url, { mode: 'no-cors' }); - - return true; - } catch (error) { - return false; - } + return fetchTimeout(url, { method: 'HEAD', mode: 'no-cors' }) + .then(() => + fetchTimeout(`https://api.allorigins.win/get?url=${encodeURIComponent(url)}`) + .then((body) => body.text()) + .then((body) => !body.includes('has been suspended')) + .catch(() => true) + ) + .catch(() => false); } async function getBalance (key) {