Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Injected.js remove .default #2822

Closed
wants to merge 1 commit into from

Conversation

maunklana
Copy link

@maunklana maunklana commented Mar 18, 2024

PR Details

a change in the function on waweb 2.3000

Description

the function is not in default key, so I remove all .default in injected.js

Related Issue

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'default')

How Has This Been Tested

Tested Sending and Receiving messages, using example from documentation

Windows 11
Android 8.1.0
Puppeter use Brave Browser
Node.js v20.9.0
WAWEB VERSION 2.3000.1012115560

Types of changes

  • Dependency change
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (index.d.ts).

@@ -5,15 +5,15 @@ exports.ExposeStore = (moduleRaidStr) => {
eval('var moduleRaid = ' + moduleRaidStr);
// eslint-disable-next-line no-undef
window.mR = moduleRaid();
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - shouldn't it be 0 as in other cases?

Suggested change
window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[1]);
window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat)[0]);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 only got the function Chat
1 gets the function as the previous default.

313551828-a6eb6fe6-7895-45ee-b502-ff8fbb7d6e52

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TY!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the reason of that is that we have many modules that have Chat function, so we need to check about something else than Chat method to define that this module is the Store, maybe if we check also for AdCollection or Blocklist or any other property we see in the picture, this will do the trick, like this:

window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat && m.Blocklist)[0]);

But it needs more test to ensure that Blocklist always found within Store module along the Chat function

Hope someone can test this and tell us if it does what we need, as currently i am not able to test it from my side !!!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have new PR

i think the reason of that is that we have many modules that have Chat function, so we need to check about something else than Chat method to define that this module is the Store, maybe if we check also for AdCollection or Blocklist or any other property we see in the picture, this will do the trick, like this:

window.Store = Object.assign({}, window.mR.findModule(m => m && m.Chat && m.Blocklist)[0]);

But it needs more test to ensure that Blocklist always found within Store module along the Chat function

Hope someone can test this and tell us if it does what we need, as currently i am not able to test it from my side !!!

@voidpack
Copy link

thx thats work. tested it on whatsapp version 2.3000.1012116664

@MoudiZd
Copy link

MoudiZd commented Mar 18, 2024

Hello,
But does these changes break old web whatsapp versions, because in this case we must think about a new way to support both new and old versions, at least till old versions are not valid by whatsapp itself anymore

@maunklana
Copy link
Author

yes, this will break the old Waweb version.
we will need a work around to support it.

Hello, But does these changes break old web whatsapp versions, because in this case we must think about a new way to support both new and old versions, at least till old versions are not valid by whatsapp itself anymore

@maunklana maunklana closed this Mar 18, 2024
mouhammad-zd added a commit to mouhammad-zd/moduleRaid that referenced this pull request Mar 18, 2024
- Add isComet as property to the moduleRaid object with a boolean value that tell if current version is comet or not.
- Add a property named `default` to the filled module and set the module itself as value of this property, in this way we do not need to make any change for the way we use findModule method inside 'injected.js', 

related pull request link : 
pedroslopez/whatsapp-web.js#2822
@maunklana
Copy link
Author

got to New PR

@MoudiZd MoudiZd mentioned this pull request Mar 31, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants