Skip to content

Commit be105c8

Browse files
committed
🚑 attempt to fix #3218
1 parent 54b0552 commit be105c8

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

src/controllers/initializer.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export async function create(config: AdvancedConfig | ConfigObject = {}): Promis
208208
*/
209209
const invariantAviodanceTs = now();
210210
await Promise.race([
211-
(waPage as Page).waitForFunction(`(()=>{return require && require("__debug").modulesMap["WAWebLoadMainBundleFileDefinitions"] ? true : false})()`, {timeout: 10000}).catch(()=>{}), //modules are loaded
211+
(waPage as Page).waitForFunction(`(()=>{return require && require("__debug").modulesMap["WAWebCollections"] ? true : false})()`, {timeout: 10000}).catch(()=>{}), //modules are loaded
212212
(waPage as Page).waitForFunction(`[...document.getElementsByTagName('div')].filter(x=>x.dataset && x.dataset.testid)[0]?.dataset?.testid === 'qrcode'`, {timeout: 10000}).catch(()=>{}), //qr code is loaded
213213
(waPage as Page).waitForFunction(`document.getElementsByTagName('circle').length===1`, {timeout: 10000}).catch(()=>{}) //qr spinner is present
214214
])
@@ -315,7 +315,10 @@ export async function create(config: AdvancedConfig | ConfigObject = {}): Promis
315315
if (canInjectEarly) {
316316
//check if page is valid after 5 seconds
317317
spinner.start('Checking if session is valid');
318-
if(config?.safeMode) await timeout(5000);
318+
if(config?.safeMode) {
319+
await timeout(5000);
320+
await injectApi(waPage, spinner, true)
321+
}
319322
}
320323
//@ts-ignore
321324
const VALID_SESSION = await waPage.waitForFunction(`window.Store && window.Store.Msg ? true : false`,{ timeout: 9000, polling: 200 }).catch(async e=>{

src/controllers/patch_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export async function getLicense(config: ConfigObject, me: {
144144

145145
export async function earlyInjectionCheck(page: Page): Promise<(page: Page) => boolean> {
146146
//@ts-ignore
147-
await page.waitForFunction(`require("__debug").modulesMap["WAWebLoadMainBundleFileDefinitions"] ? true : false`, { timeout: 10, polling: 500 }).catch(()=>{})
147+
await page.waitForFunction(`require("__debug").modulesMap["WAWebCollections"] ? true : false`, { timeout: 10, polling: 500 }).catch(()=>{})
148148
//@ts-ignore
149149
// return await page.evaluate(() => { if (window.webpackChunkwhatsapp_web_client) { window.webpackChunkbuild = window.webpackChunkwhatsapp_web_client; } else { (function () { const f = Object.entries(window).filter(([, o]) => o && o.push && (o.push != [].push)); if (f[0]) { window.webpackChunkbuild = window[f[0][0]]; } })(); } return (typeof window.webpackChunkbuild !== "undefined"); });
150150
return true;

src/lib/launch.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/wapi.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ if (!window.Store || !window.Store.Msg) {
4646
let neededModule = require(needObj.module)
4747
needObj.foundedModule = neededModule;
4848
});
49-
window.Store = {...Object.values(require("__debug").modulesMap["WAWebLoadMainBundleFileDefinitions"]?.exports || {}).map(x=>{
50-
const module = x();
51-
const collectionName = module.modelClass?.prototype?.proxyName
52-
if(!collectionName) return false;
53-
const capName = collectionName.charAt(0).toUpperCase() + collectionName.slice(1);
54-
return [capName, module]
55-
}).filter(x=>x).reduce((acc,curr) => {return {...acc,[curr[0]]: curr[1]}}, {}),
56-
...(window.Store || {})}
49+
window.Store = {...{...require("WAWebCollections")},...(window.Store || {})}
5750
neededObjects.forEach((needObj) => {
5851
if (needObj.foundedModule) {
5952
window.Store[needObj.id] = needObj.resolver ? needObj.resolver(needObj.foundedModule) : needObj.foundedModule;

0 commit comments

Comments
 (0)