mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
feat: use specific whatsapp web version
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user