From b7c2b0521404e8a1b61ea72e7d46345e0c5a2a85 Mon Sep 17 00:00:00 2001 From: Supernova Date: Wed, 29 Jul 2020 01:06:56 +0000 Subject: [PATCH] Add php script to check HackerNews if javascript fails --- assets/scripts.js | 20 ++++++++++++++++++-- server/verifyHackerNews.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 server/verifyHackerNews.php diff --git a/assets/scripts.js b/assets/scripts.js index 2b40b75..2c0ad18 100644 --- a/assets/scripts.js +++ b/assets/scripts.js @@ -464,9 +464,25 @@ async function verifyProof(url, fingerprint) { output.isVerified = true; } } catch (e) { - } finally { - return output; } + + if(output.isVerified == false) { + output.proofUrlFetch = `/server/verifyHackerNews.php?user=${match[1]}&fp=${fingerprint}`; + try { + response = await fetch(output.proofUrlFetch, { + headers: { + Accept: 'application/json' + }, + credentials: 'omit' + }); + if (!response.ok) { + throw new Error('Response failed: ' + response.status); + } + json = await response.json(); + output.isVerified = json.verified; + } catch (e) { } + } + return output; } // dev.to if (/^https:\/\/dev\.to\//.test(url)) { diff --git a/server/verifyHackerNews.php b/server/verifyHackerNews.php new file mode 100644 index 0000000..bfa9089 --- /dev/null +++ b/server/verifyHackerNews.php @@ -0,0 +1,28 @@ +