Webwhatsapp-wrapper: Error on load modules (Chat and Msg)

Created on 3 Jun 2020  路  11Comments  路  Source: mukulhase/WebWhatsapp-Wrapper

unfortunately WhatsApp has changed the way of encapsulating the modules. For this, I created this PR adapting for both versions.

https://github.com/mukulhase/WebWhatsapp-Wrapper/pull/888/files

Most helpful comment

.app
its now just .two
"mainPage": ".two",

All 11 comments

In addition to your change, after logging in with the "wait_for_login" function, change the 'mainPage' attribute

location file: webwhatsapi wapi_js_wrapper.py

'mainPage': ".app.two"

by

'mainPage': ".app.h70RQ.two"

These changes didn't work to me in version 2.2023.2 of whatsapp web. Store.Chat dont work.

working

if (!window.Store) {
(function () {
function getStore(modules) {
let foundCount = 0;
let neededObjects = [
{ id: "Store", conditions: (module) => (module.Chat && module.Msg) ? module : null },
{ id: "MediaCollection", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.processAttachments) ? module.default : null },
{ id: "MediaProcess", conditions: (module) => (module.BLOB) ? module : null },
{ id: "Wap", conditions: (module) => (module.createGroup) ? module : null },
{ id: "ServiceWorker", conditions: (module) => (module.default && module.default.killServiceWorker) ? module : null },
{ id: 'Presence', conditions: (value) => (value.default && value.default.Presence) ? value.default : null },
{ id: "State", conditions: (module) => (module.STATE && module.STREAM) ? module : null },
{ id: "WapDelete", conditions: (module) => (module.sendConversationDelete && module.sendConversationDelete.length == 2) ? module : null },
{ id: "Conn", conditions: (module) => (module.default && module.default.ref && module.default.refTTL) ? module.default : null },
{ id: "WapQuery", conditions: (module) => (module.queryExist) ? module : ((module.default && module.default.queryExist) ? module.default : null) },
{ id: "CryptoLib", conditions: (module) => (module.decryptE2EMedia) ? module : null },
{ id: "OpenChat", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.openChat) ? module.default : null },
{ id: "UserConstructor", conditions: (module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null },
{ id: "SendTextMsgToChat", conditions: (module) => (module.sendTextMsgToChat) ? module.sendTextMsgToChat : null },
{ id: "SendSeen", conditions: (module) => (module.sendSeen) ? module.sendSeen : null },
{ id: "sendDelete", conditions: (module) => (module.sendDelete) ? module.sendDelete : null }
];
for (let idx in modules) {
if ((typeof modules[idx] === "object") && (modules[idx] !== null)) {
let first = Object.values(modules[idx])[0];
if ((typeof first === "object") && (first.exports)) {
for (let idx2 in modules[idx]) {
let module = modules(idx2);
if (!module) {
continue;
}
neededObjects.forEach((needObj) => {
if (!needObj.conditions || needObj.foundedModule)
return;
let neededModule = needObj.conditions(module);
if (neededModule !== null) {
foundCount++;
needObj.foundedModule = neededModule;
}
});
if (foundCount == neededObjects.length) {
break;
}
}

                    let neededStore = neededObjects.find((needObj) => needObj.id === "Store");
                    window.Store = neededStore.foundedModule ? neededStore.foundedModule : {};
                    neededObjects.splice(neededObjects.indexOf(neededStore), 1);
                    neededObjects.forEach((needObj) => {
                        if (needObj.foundedModule) {
                            window.Store[needObj.id] = needObj.foundedModule;
                        }
                    });
                    window.Store.sendMessage = function (e) {
                        return window.Store.SendTextMsgToChat(this, ...arguments);
                    };

                    if (window.Store.Presence) {
                        for (const prop in window.Store.Presence) {
                            if (prop === "Presence") {
                                continue;
                            }
                            console.log(prop);
                            window.Store[prop] = window.Store.Presence[prop] || window.Store[prop];
                        }
                    }

                    return window.Store;
                }
            }
        }



    }

    if (typeof webpackJsonp === 'function') {
        webpackJsonp([], {'parasite': (x, y, z) => getStore(z)}, ['parasite']);
    } else {
        webpackJsonp.push([
            ['parasite'],
            {
                parasite: function (o, e, t) {
                    getStore(t);
                }
            },
            [['parasite']]
        ]);
    }

})();

}

Tested solution and worked well on 2.2023.2!!

Thanks for @felippeefreire and @chirag90851 for solving this issue so fastly \o/\o/\o/

Hi Guys

I tried on Whatsapp Web version 2.2023.2 this:

https://raw.githubusercontent.com/mukulhase/WebWhatsapp-Wrapper/master/webwhatsapi/js/wapi.js

Showed up message below:

Uncaught TypeError: window.Store.Msg is undefined
debugger eval code:1144

I did a test in old version works fine.

Hi @ijoaobatista Workfine now.
Many thanks.
Cheers...

.app
its now just .two
"mainPage": ".two",

@mhndm Thank you!!!

after changing it to .two
got another issue:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.JavascriptException: Message: TypeError: window.Store.Msg is undefined

which upon finding this issue we changed time.sleep(5) to time.sleep(60)
but that too didn't help.

what do you think is the issue @mukulhase ?

These changes didn't work to me in version 2.2023.2 of whatsapp web. Store.Chat dont work.

And many other modules don't work too....

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drsoporte picture drsoporte  路  5Comments

rzlnhd picture rzlnhd  路  3Comments

ItachiL18 picture ItachiL18  路  6Comments

NolanWang picture NolanWang  路  5Comments

FeezyHendrix picture FeezyHendrix  路  3Comments