tweak: cosmetic improvments to good judgment fetcher

This commit is contained in:
NunoSempere 2022-04-09 23:21:24 -04:00
parent 7aa44746bf
commit 789fafd0f6

View File

@ -139,17 +139,17 @@ function isSignedIn(html) {
if (!isSignedInBool) { if (!isSignedInBool) {
console.log("Error: Not signed in."); console.log("Error: Not signed in.");
} }
console.log(`is signed in? ${isSignedInBool}`); console.log(`is signed in? ${isSignedInBool ? "yes" : "no"}`);
return isSignedInBool; return isSignedInBool;
} }
function isEnd(html) { function reachedEnd(html) {
let isEndBool = html.includes("No questions match your filter"); let reachedEndBool = html.includes("No questions match your filter");
if (isEndBool) { if (reachedEndBool) {
//console.log(html) //console.log(html)
} }
console.log(`IsEnd? ${isEndBool}`); console.log(`Reached end? ${reachedEndBool}`);
return isEndBool; return reachedEndBool;
} }
function sleep(ms: number) { function sleep(ms: number) {
@ -165,7 +165,7 @@ async function goodjudgmentopen_inner(cookie) {
let results = []; let results = [];
let init = Date.now(); let init = Date.now();
// console.log("Downloading... This might take a couple of minutes. Results will be shown.") // console.log("Downloading... This might take a couple of minutes. Results will be shown.")
while (!isEnd(response) && isSignedIn(response)) { while (!reachedEnd(response) && isSignedIn(response)) {
let htmlLines = response.split("\n"); let htmlLines = response.split("\n");
DEBUG_MODE == "on" ? htmlLines.forEach((line) => console.log(line)) : id(); DEBUG_MODE == "on" ? htmlLines.forEach((line) => console.log(line)) : id();
let h5elements = htmlLines.filter((str) => str.includes("<h5> <a href=")); let h5elements = htmlLines.filter((str) => str.includes("<h5> <a href="));