From dc6e5db8380a0bd0b2f56d4f1e4a9c88d6f7ab66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3nalan=20de=20Lima?= Date: Mon, 15 Nov 2021 13:14:07 -0300 Subject: [PATCH] fix: webpack --- src/lib/wapi/wapi.js | 65 ++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/lib/wapi/wapi.js b/src/lib/wapi/wapi.js index 42cc22e00..0ecea4f30 100644 --- a/src/lib/wapi/wapi.js +++ b/src/lib/wapi/wapi.js @@ -193,37 +193,44 @@ import { _serializeRawObj, _serializeMeObj } from './serializers'; -import { storeObjects } from './store/store-objects'; -import getStore from './store/get-store'; -window['webpackJsonp'] = window['webpackJsonp'] || []; -window['webpackChunkbuild'] = window['webpackChunkbuild'] || []; - -if (typeof window.Store === 'undefined') { - window.Store = {}; - window.Store.promises = {}; - const f_modules = new getStore(); - window.Store.loader = f_modules; - - for (const store of storeObjects) { - Store.promises[store.id] = f_modules - .waitForModule((m) => !!store.conditions(m)) - .then(store.conditions) - .then((m) => { - if (store.id === 'Store') { - window.Store = Object.assign({}, window.Store, m); - } else { - window.Store[store.id] = m; +import { getStore } from './store/get-store'; + +window['webpackChunkwhatsapp_web_client'] = + window['webpackChunkwhatsapp_web_client'] || []; +window.Store = {}; +var loadParasite = function () { + function injectParasite() { + const parasite = `parasite`; + window['webpackChunkwhatsapp_web_client'].push([ + [parasite], + {}, + async function (o) { + let modules = []; + for (let idx in o.m) { + modules.push(o(idx)); } - }); + getStore(modules); + } + ]); } - - window.Store.sendMessage = function (e) { - return window.Store.SendTextMsgToChat(this, ...arguments); - }; - window.Store.sendAddMessage = function (e) { - return window.Store.addAndSendMsgToChat(this, ...arguments); - }; -} + setInterval(() => { + try { + const last = window['webpackChunkwhatsapp_web_client'].length - 1; + if ( + !window['webpackChunkwhatsapp_web_client'][last][0].includes( + 'parasite' + ) && + (document.querySelectorAll('#app').length || + document.querySelectorAll('#app .two').length || + document.querySelector('canvas') || + document.querySelectorAll('#startup').length == 0) + ) { + injectParasite(); + } + } catch (e) {} + }, 100); +}; +loadParasite(); if (typeof window.WAPI === 'undefined') { window.WAPI = {