Skip to content

Commit

Permalink
resolving whatsapp update issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasani-arpit committed Sep 28, 2019
1 parent ebe1e2a commit 12c7a7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ typings/

# next.js build output
.next
ChromeSession
ChromeSession*
win*
chromium-data
18 changes: 14 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,7 @@ async function Main() {
page.addStyleTag({ path: path.join(__dirname, "style.css") });
}
//console.log(contents);
var filepath = path.join(__dirname, "WAPI.js");
await page.addScriptTag({ path: require.resolve(filepath) });
filepath = path.join(__dirname, "inject.js");
await page.addScriptTag({ path: require.resolve(filepath) });
await injectScripts(page);
botjson.then((data) => {
page.evaluate("var intents = " + data);
//console.log(data);
Expand All @@ -111,6 +108,19 @@ async function Main() {
}
}

async function injectScripts(page) {
page.waitForSelector('[data-icon=laptop]')
.then(async () => {
var filepath = path.join(__dirname, "WAPI.js");
await page.addScriptTag({ path: require.resolve(filepath) });
filepath = path.join(__dirname, "inject.js");
await page.addScriptTag({ path: require.resolve(filepath) });
})
.catch(() => {
console.log("User is not logged in. Waited 30 seconds.");
})
}

async function checkLogin() {
spinner.start("Page is loading");
//TODO: avoid using delay and make it in a way that it would react to the event.
Expand Down

0 comments on commit 12c7a7d

Please sign in to comment.