feat: use specific whatsapp web version

This commit is contained in:
Pedro Lopez
2022-11-26 18:17:19 -04:00
parent 6fe1017bd3
commit afb0b5d7d3
3 changed files with 35 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
const Util = require('./util/Util');
const InterfaceController = require('./util/InterfaceController');
const { getIndexForVersion } = require('./util/VersionResolver');
const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constants');
const { ExposeStore, LoadUtils } = require('./util/Injected');
const ChatFactory = require('./factories/ChatFactory');
@@ -108,6 +109,7 @@ class Client extends EventEmitter {
this.pupPage = page;
await this.authStrategy.afterBrowserInitialized();
await this.initVersionOverride();
await page.goto(WhatsWebURL, {
waitUntil: 'load',
@@ -562,6 +564,22 @@ class Client extends EventEmitter {
});
}
async initVersionOverride() {
const version = this.options.webVersion;
await this.pupPage.setRequestInterception(true);
this.pupPage.on('request', async (req) => {
if(req.url() === WhatsWebURL) {
req.respond({
status: 200,
contentType: 'text/html',
body: await getIndexForVersion(version)
});
} else {
req.continue();
}
});
}
/**
* Closes the client
*/