diff --git a/web/index.html b/web/index.html index e5a4891..6bc09c3 100644 --- a/web/index.html +++ b/web/index.html @@ -8,24 +8,23 @@

Request on Hold

-
-
- - +
+
-
+ +

If you suspect that you are being blocked by mistake, make sure that you have the latest browser version installed and all active browser plugins are disabled.

- +

If you see this and the verification repeats, please try a different browser.

-
+
+
diff --git a/web/src/challange/challanger.js b/web/src/challange/challanger.js index 3e7429f..66e4ca5 100644 --- a/web/src/challange/challanger.js +++ b/web/src/challange/challanger.js @@ -1,4 +1,5 @@ -import {challengeFingerprinting, challengeNone, challengePOW, challengeUnknown} from "./challanges"; +import {getChallengeSolver} from "./challanges"; +import * as loader from "./loader.js"; /** * Decide and solve browser challenges. @@ -20,21 +21,33 @@ async function getChallenge() { * @return {Promise} */ export async function doChallenge() { - const challenge = await getChallenge(); - const {t} = challenge; - - const challengeFunc = (() => { - switch (t) { - case 0: - return challengeNone; - case 1: - return challengePOW; - case 2: - return challengeFingerprinting; - default: - return challengeUnknown; + loader.start(); + + let result; + try { + loader.setChallengeInfo("Fetching challenge...") + + const challenge = await getChallenge(); + const {t} = challenge; + + const [name, solver] = getChallengeSolver(t); + + loader.setChallengeInfo(name) + result = await solver(challenge); + if (!!result) { + result = `Validation result: ${result}`; } - })() + } catch (e) { + result = e.toString(); + } + + loader.stop(!!result); + if (result) { + loader.showError(result); + return; + } - return await challengeFunc(challenge) + setTimeout(() => { + window.location.reload(); + }, 3000); } diff --git a/web/src/challange/challanges.js b/web/src/challange/challanges.js index 483ad48..be07640 100644 --- a/web/src/challange/challanges.js +++ b/web/src/challange/challanges.js @@ -23,7 +23,7 @@ async function nativeHash(data, method) { * @param {object} challenge * @return {Promise} */ -export async function challengePOW(challenge) { +async function challengePOW(challenge) { let hash; let i; // eslint-disable-next-line no-constant-condition @@ -45,7 +45,7 @@ export async function challengePOW(challenge) { * * @return {Promise} */ -export async function challengeFingerprinting() { +async function challengeFingerprinting() { const usualUa = isUsualBrowserBasedOnUa(); if (!usualUa) return "ua"; @@ -63,18 +63,21 @@ export async function challengeFingerprinting() { * * @return {Promise} */ -export async function challengeNone() { +async function challengeNone() { return new Promise((resolve) => { setTimeout(resolve, 3000); }); } -/** - * Unknown challenge from server. - * Reload page. - * - * @return {Promise} - */ -export async function challengeUnknown() { - window.location.reload(); +export function getChallengeSolver(challengeType) { + switch (challengeType) { + case 0: + return ["Please wait...", challengeNone]; + case 1: + return ["Solving POW challenge...", challengePOW]; + case 2: + return ["Validating browser fingerprint...", challengeFingerprinting]; + default: + throw new Error(`Unknown challenge type: ${challengeType}`); + } } \ No newline at end of file diff --git a/web/src/challange/loader.js b/web/src/challange/loader.js index 3907a41..8d2d31c 100644 --- a/web/src/challange/loader.js +++ b/web/src/challange/loader.js @@ -12,7 +12,12 @@ export function start() { export function showError(error) { const errors = /** @type {HTMLDivElement} */ (document.querySelector(".error-container")); - errors.insertAdjacentHTML("beforeend", `

Error: ${error}

`) + errors.insertAdjacentHTML("beforeend", `${error}`) +} + +export function setChallengeInfo(text) { + const captcha = /** @type {HTMLDivElement} */ (document.querySelector(".captcha")); + captcha.innerText = text; } /** diff --git a/web/src/main.js b/web/src/main.js index c0d2ffe..f0a93c3 100644 --- a/web/src/main.js +++ b/web/src/main.js @@ -1,6 +1,5 @@ import "./style.scss"; import {doChallenge} from "./challange/challanger"; -import * as loader from "./challange/loader.js"; (() => { @@ -10,18 +9,6 @@ import * as loader from "./challange/loader.js"; if (noCookie) noCookie.style.display = "block"; } - loader.start(); - try { - const result = await doChallenge() - loader.stop(!!result); - } catch (e) { - loader.showError(e) - loader.stop(true); - return; - } - - setTimeout(() => { - window.location.reload(); - }, 1000); + await doChallenge(); }); })(); diff --git a/web/src/style.scss b/web/src/style.scss index 815ef4e..6fd4767 100644 --- a/web/src/style.scss +++ b/web/src/style.scss @@ -2,9 +2,10 @@ .container { display: flex; - flex-direction: row; justify-content: center; + flex-wrap: wrap; align-items: center; + align-content: center; position: absolute; width: 100%; height: 100%; @@ -22,6 +23,25 @@ font-weight: bold; } } + > .break { + flex-basis: 100%; + height: 0; + } +} + +.footer { + bottom: 1em; + position: absolute; +} + +code { + padding: 16px; + overflow: auto; + line-height: 1.45; + background-color: #f7f7f7; + border-radius: 3px; + max-width: 80vw; + display: block; } .logo { @@ -44,11 +64,16 @@ margin: .5em 0 .5em 0; } +.captcha { + margin-left: auto; + font-size: 120%; +} + $circleSize: 3em; .circle-loader { visibility: hidden; - margin-left: auto; + margin-left: 1em; border: 1px solid rgba(0, 0, 0, 0.2); border-left-color: #000; animation: loader-spin 1.2s infinite linear;