This commit is contained in:
TheNetsky
2023-09-26 12:04:34 +02:00
parent c802492f18
commit 2291245657
7 changed files with 128 additions and 47 deletions

View File

@@ -47,10 +47,12 @@ export async function doQuiz(page: Page, data: PromotionalItem | MorePromotion)
}
}
// Click the answers
for (const answer of answers) {
await wait(2000)
// Click the answer on page
await quizPage.click(answer)
await wait(1500)
const refreshSuccess = await waitForQuizRefresh(quizPage)
if (!refreshSuccess) {
@@ -72,7 +74,7 @@ export async function doQuiz(page: Page, data: PromotionalItem | MorePromotion)
if (dataOption === correctOption) {
// Click the answer on page
await quizPage.click(`#rqAnswerOption${i}`)
await wait(1500)
await wait(2000)
const refreshSuccess = await waitForQuizRefresh(quizPage)
if (!refreshSuccess) {
@@ -88,6 +90,7 @@ export async function doQuiz(page: Page, data: PromotionalItem | MorePromotion)
}
// Done with
await wait(2000)
await quizPage.close()
log('QUIZ', 'Completed the quiz successfully')
} catch (error) {

View File

@@ -2,7 +2,7 @@ import { Page } from 'puppeteer'
import axios from 'axios'
import { log } from '../../util/Logger'
import { shuffleArray, wait } from '../../util/Utils'
import { wait } from '../../util/Utils'
import { getSearchPoints } from '../../BrowserFunc'
import { DashboardData, DashboardImpression } from '../../interface/DashboardData'
@@ -29,7 +29,8 @@ export async function doSearch(page: Page, data: DashboardData, mobile: boolean)
}
// Generate search queries
const googleSearchQueries = shuffleArray(await getGoogleTrends(locale, missingPoints))
const googleSearchQueries = await getGoogleTrends(locale, missingPoints)
//const googleSearchQueries = shuffleArray(await getGoogleTrends(locale, missingPoints))
// Open a new tab
const browser = page.browser()
@@ -162,7 +163,7 @@ async function bingSearch(page: Page, searchPage: Page, query: string) {
}
async function getGoogleTrends(locale: string, queryCount: number): Promise<string[]> {
const queryTerms: string[] = []
let queryTerms: string[] = []
let i = 0
while (queryCount > queryTerms.length) {
@@ -193,10 +194,7 @@ async function getGoogleTrends(locale: string, queryCount: number): Promise<stri
}
// Deduplicate the search terms
const uniqueSearchTerms = Array.from(new Set(queryTerms))
queryTerms.length = 0
queryTerms.push(...uniqueSearchTerms)
queryTerms = [...new Set(queryTerms)]
} catch (error) {
log('SEARCH-GOOGLE-TRENDS', 'An error occurred:' + error, 'error')
}