Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to enable owl for Ehaj #221

Merged
merged 9 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/ehj.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ async function pageContentHandler(currentConfig) {
`\n${counter} - ${startTime} - ${passenger?.slug}\n${passenger.codeline}\n`
);

if (global.headless) {
if (global.headless && !fs.existsSync(getPath("loop.txt"))) {
fs.writeFileSync(getPath("loop.txt"), "ehaj", "utf-8");
}
await util.toggleBlur(page, false);
Expand All @@ -860,12 +860,31 @@ async function pageContentHandler(currentConfig) {
} else {
await util.controller(page, currentConfig, data.travellers);
}
await page.waitForSelector("#proceedButton > input.btn.btn-primary", {
visible: true,
timeout: 0,
});
await page.waitForTimeout(2000);
await page.click("#proceedButton > input.btn.btn-primary");
try {
await page.waitForSelector("#proceedButton > input.btn.btn-primary", {
visible: true,
timeout: 5000,
});
await page.click("#proceedButton > input.btn.btn-primary");
} catch (err) {
const error = await page.$eval("#passportCaptureStatus", (el) => {
return el.innerText;
});
if (error.includes("try again")) {
await kea.updatePassenger(
data.system.accountId,
passenger.passportNumber,
{
"submissionData.ehj.status": "Rejected",
"submissionData.ehj.RejectedReason": error,
}
);

util.incrementSelectedTraveler();
await page.reload();
return false;
}
}
break;
case "add-mission-pilgrim-upload":
await util.controller(page, currentConfig, data.travellers);
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ async function initPage(config, onContentLoaded, data) {
args,
};

if (!isCloudRun && !isHeadless) {
if (process.argv.includes("--debug") || (!isCloudRun && !isHeadless)) {
launchOptions.executablePath = getChromePath();
}
browser = await puppeteer.launch(launchOptions);
Expand Down
Loading