Skip to content

Commit

Permalink
feat: forcing injectApi
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Feb 25, 2022
1 parent ec89f4e commit f5404ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/controllers/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export async function initWhatsapp(
await browser.userAgent();
// Auth with token
await auth_InjectToken(waPage, session, options, token);
await waPage.evaluate(() => {
window.location.reload();
});

return waPage;
} catch {
waPage.close().catch(() => {});
Expand Down
16 changes: 10 additions & 6 deletions src/controllers/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@ MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

import * as chalk from 'chalk';

import * as fs from 'fs';

import { fstat, readFileSync } from 'fs';
import { readFileSync } from 'fs';

import { Browser, Page } from 'puppeteer';

import path = require('path');

import { deleteFiles, checkingCloses } from '../api/helpers';
import { Whatsapp } from '../api/whatsapp';
import { CreateConfig, defaultOptions } from '../config/create-config';
import { tokenSession } from '../config/tokenSession.config';
import { checkFileJson } from '../api/helpers/check-token-file';
import { SocketState, SocketStream } from '../api/model/enum';
import { SessionTokenCkeck, saveToken, isBeta } from './auth';
import { initWhatsapp, initBrowser } from './browser';
import { initWhatsapp, initBrowser, injectApi } from './browser';
import { welcomeScreen } from './welcome';
/**
* A callback will be received, informing the status of the qrcode
Expand Down Expand Up @@ -336,6 +332,10 @@ export async function create(
}
});

page.on('dialog', async (dialog) => {
await dialog.accept();
});

if (mergedOptions.waitForLogin) {
const isLogged = await client.waitForLogin(catchQR, statusFind);
if (!isLogged) {
Expand Down Expand Up @@ -367,7 +367,9 @@ export async function create(
).slice(0, -54)}`;
console.log(`\nDebug: \x1b[34m${debugURL}\x1b[0m`);
}

await page.waitForSelector('#app .two', { visible: true }).catch(() => {});

await page
.waitForFunction(
() => {
Expand All @@ -386,6 +388,8 @@ export async function create(
)
.catch(() => {});

await injectApi(page);

return client;
}
}

0 comments on commit f5404ba

Please sign in to comment.