Zzombiee2361 / whatsapp-web-electron.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web in electron
Apache License 2.0
24 stars 10 forks source link

LegacyPhoneFeatures issue in Injected.js (fixed in official whatsapp-web.js) #31

Open Minenat69 opened 1 year ago

Minenat69 commented 1 year ago

Is there an existing issue for this?

Describe the bug

In Injected.js line 16, there is a line that causes Client initialize crash even if connection is good You basically just have to comment this line to fix it, or you can get last version of whatsapp-web.js that also fixed the issue :

src/utils/Injected.js
[...]
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
// You just have to comment this line
// window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].LegacyPhoneFeatures;
window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
window.Store.InviteInfo = window.mR.findModule('sendQueryGroupInvite')[0];
[...]

Expected behavior

I don't know why this line makes the creation bug, but sometimes window.mR.findModule('FEATURE_CHANGE_EVENT')[0] is not defined, so getting the index at 0 catches an error.

You can simply replace it by :

    const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
    if(_features) {
        window.Store.Features = _features.LegacyPhoneFeatures;
    }

(That's what they did in wweb-js)

Steps to Reproduce the Bug or Issue

Create a new Client

Relevant Code

No response

Browser Type

Other (please write in Additional Context)

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

Os : Windows Phone : Iphone wweb.js-electron : last

Additional context

No response

Zzombiee2361 commented 1 year ago

Please check if this still happens with the new version