This commit is contained in:
Dung Nguyen 2022-02-27 16:41:45 +07:00
parent a373b42688
commit 7486cfc48e

View File

@ -88,19 +88,24 @@ puppeteer
let count; let count;
const printResponse = async function (cdp, response) { const printResponse = async function (cdp, response) {
if (!response.response) { if (!response.response || !page || !page.evaluate) {
return; return;
} }
let data = response.response.payloadData; let data = response.response.payloadData;
if (data.includes("BO_PRICE")) { if (data.includes("BO_PRICE")) {
const isDisableBtn = await page.evaluate(() => { let isDisableBtn = false;
if (!document) return false; try {
const btnCheck = document.querySelector( isDisableBtn = await page.evaluate(() => {
"#betAmount > div:nth-child(5) > div > div:nth-child(1) > button" if (!document) return false;
); const btnCheck = document.querySelector(
return btnCheck && !btnCheck.hasAttribute("disabled"); "#betAmount > div:nth-child(5) > div > div:nth-child(1) > button"
}); );
return btnCheck && !btnCheck.hasAttribute("disabled");
});
} catch (error) {
console.log(`Không tìm thấy page!`);
}
currentSessionID = isDisableBtn ? JSON.parse(data.substr(2, data.length))[1].session : -1; currentSessionID = isDisableBtn ? JSON.parse(data.substr(2, data.length))[1].session : -1;
// if (currentSessionID !== -1) console.log(currentSessionID); // if (currentSessionID !== -1) console.log(currentSessionID);