Skip to content

Commit

Permalink
Merge branch 'qr-codes-not-being-extracted'
Browse files Browse the repository at this point in the history
  • Loading branch information
ghayman committed Nov 10, 2024
2 parents 97a8206 + a21267d commit daed3d3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ try {
session: 'sessionName_0001',
headless: false,
devtools: true,
useChrome: false,
})
.then((client) => start(client))
.catch(async (err) => {
Expand All @@ -27,6 +28,11 @@ async function start(client) {
console.log(JSON.stringify(pid, null, 2));

console.log(await client.isLoggedIn());
const hostData = await client.getHost();
if(hostData && hostData.id) {
console.log(hostData.id);
}


let lastMessageId = "";

Expand All @@ -48,6 +54,16 @@ async function start(client) {
}
});

client.onStateChange((state) => {
console.log("State change: " + client.session);
console.log("State change: " + state);
})

client.onStreamChange((stream) => {
console.log("Stream change: " + client.session);
console.log("Stream change: " + stream);
})

client.onMessageEdit((message) => {
console.log('EDIT!');
console.log(message);
Expand Down
7 changes: 7 additions & 0 deletions src/api/layers/host.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ export class HostLayer {
return await this.page.evaluate(() => WAPI.isLoggedIn());
}

/**
* Retrieves information about the host including who is logged in
*/
public async getHost() {
return await this.page.evaluate(() => WAPI.getHost());
}

/**
* Retrieves Battery Level
*/
Expand Down
11 changes: 8 additions & 3 deletions src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ export const getInterfaceStatus = async (waPage: puppeteer.Page) => {
if (erroHTTP && erroHTTP[0].innerText.includes('HTTP ERROR 429')) {
return { type: erroHTTP[0].innerText };
}
const elLoginWrapper = document.querySelector(
const elLoginWrapper1 = document.querySelector(
'body > div > div > .landing-wrapper'
);
const elLoginWrapper2 = document.querySelector(
'body > div > div > div > .landing-wrapper'
);
const elLoginWrapper3 = document.querySelector(
'body > div > div > div > div > div > .x1lliihq'
);

const elQRCodeCanvas = document.querySelector('canvas');
if (
(elLoginWrapper && elQRCodeCanvas) ||
(elLoginWrapper2 && elQRCodeCanvas)
(elLoginWrapper1 && elQRCodeCanvas) ||
(elLoginWrapper2 && elQRCodeCanvas) ||
(elLoginWrapper3 && elQRCodeCanvas)
) {
return 'UNPAIRED';
}
Expand Down

0 comments on commit daed3d3

Please sign in to comment.