fix: Reworked logic to better deal with being logged out in CultivateLabs platforms
This commit is contained in:
parent
87db98ec45
commit
d9390faeec
|
@ -131,11 +131,17 @@ async function fetchStats(questionUrl, cookie){
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEnd(html){
|
function isNotSignedIn(html){
|
||||||
if(html.includes("You need to sign in or sign up before continuing")){
|
|
||||||
throw Error("You need to sign in or sign up before continuing")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
let isNotSignedInBool = html.includes("You need to sign in or sign up before continuing") || html.includes("Sign up")
|
||||||
|
if(isNotSignedInBool){
|
||||||
|
console.log("Error: Not signed in.")
|
||||||
|
}
|
||||||
|
console.log(`isNotSignedIn? ${isNotSignedInBool}`)
|
||||||
|
return isNotSignedInBool
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEnd(html){
|
||||||
let isEndBool = html.includes("No questions match your filter")
|
let isEndBool = html.includes("No questions match your filter")
|
||||||
if(isEndBool){
|
if(isEndBool){
|
||||||
//console.log(html)
|
//console.log(html)
|
||||||
|
@ -156,7 +162,7 @@ async function csetforetell_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)){
|
while(!isEnd(response) && !isNotSignedIn(response)){
|
||||||
|
|
||||||
let htmlLines = response.split("\n")
|
let htmlLines = response.split("\n")
|
||||||
let h4elements = htmlLines.filter(str => str.includes("<h5><a href=") || str.includes("<h4><a href="))
|
let h4elements = htmlLines.filter(str => str.includes("<h5><a href=") || str.includes("<h4><a href="))
|
||||||
|
|
|
@ -107,11 +107,23 @@ async function fetchStats(questionUrl, cookie) {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEnd(html) {
|
function isNotSignedIn(html){
|
||||||
if(html.includes("You need to sign in or sign up before continuing")){
|
|
||||||
throw Error("You need to sign in or sign up before continuing")
|
let isNotSignedInBool = html.includes("You need to sign in or sign up before continuing") || html.includes("Sign up")
|
||||||
|
if(isNotSignedIn){
|
||||||
|
console.log("Error: Not signed in.")
|
||||||
}
|
}
|
||||||
return html.includes("No questions match your filter")
|
console.log(`isNotSignedIn? ${isNotSignedInBool}`)
|
||||||
|
return isNotSignedInBool
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEnd(html){
|
||||||
|
let isEndBool = html.includes("No questions match your filter")
|
||||||
|
if(isEndBool){
|
||||||
|
//console.log(html)
|
||||||
|
}
|
||||||
|
console.log(`IsEnd? ${isEndBool}`)
|
||||||
|
return isEndBool
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleep(ms) {
|
function sleep(ms) {
|
||||||
|
@ -126,7 +138,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)) {
|
while(!isEnd(response) && !isNotSignedIn(response)){
|
||||||
// console.log(`Page #${i}`)
|
// console.log(`Page #${i}`)
|
||||||
let htmlLines = response.split("\n")
|
let htmlLines = response.split("\n")
|
||||||
let h5elements = htmlLines.filter(str => str.includes("<h5><a href="))
|
let h5elements = htmlLines.filter(str => str.includes("<h5><a href="))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user