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

[Bug] Uncaught TypeError: window[this.entrypoint] is not a function #14

Open
KaKi87 opened this issue May 31, 2022 · 8 comments
Open

[Bug] Uncaught TypeError: window[this.entrypoint] is not a function #14

KaKi87 opened this issue May 31, 2022 · 8 comments

Comments

@KaKi87
Copy link

KaKi87 commented May 31, 2022

Hello,

I am getting the following error when calling new ModuleRaid() :

Uncaught TypeError: window[this.entrypoint] is not a function
    at o.fillModules (moduleraid.ts:201:24)
    at new e (moduleraid.ts:139:10)

Thanks

@pixeldesu
Copy link
Owner

What website are you trying to run moduleRaid on?

If webpackJsonp is not available in window you need to specify a custom entrypoint (e.g. https://moduleraid.netlify.app/classes/moduleraid.moduleraid#constructor)

@KaKi87
Copy link
Author

KaKi87 commented May 31, 2022

What website are you trying to run moduleRaid on?

On chat2.kaki87.net, which is my own fosscord instance.
More precisely, I'd like to remove the DoB fieldset, which is easy, except the form won't submit, which means I also need to access the React component and set a default value (e.g. 1970-01-01) to unblock it.

If webpackJsonp is not available in window you need to specify a custom entrypoint (e.g. https://moduleraid.netlify.app/classes/moduleraid.moduleraid#constructor)

I saw that, which isn't necessary in this case.

Thanks !

@pixeldesu
Copy link
Owner

Hmm, if I run the script on the page via the console it works fine.

I don't know how you are implementing moduleRaid but maybe you are too early then (moduleRaid tries to call the entrypoint as a function as the last resort, which was some legacy Webpack bundling way)

@KaKi87
Copy link
Author

KaKi87 commented Jun 1, 2022

I don't know how you are implementing moduleRaid

Using the following code :

{
    const script = document.createElement('script');
    script.setAttribute('src', 'https://unpkg.com/moduleraid/dist/moduleraid.iife.js');
    script.addEventListener('load', () => window.mR = new ModuleRaid());
    document.head.appendChild(script);
}

but maybe you are too early then

Would waiting for DOMContentLoaded be enough ?

moduleRaid tries to call the entrypoint as a function as the last resort

What does it uses first then ?

Thanks

@ihsankl
Copy link

ihsankl commented Jun 23, 2022

I got the same error while trying on whatsapp client before login.

image

@pixeldesu
Copy link
Owner

Yeah, I saw the errors prop up a bit more often in other projects too.

I'll see about fixing that injection method, so it doesn't throw errors anymore at least.

@lucasfq
Copy link

lucasfq commented Oct 5, 2022

Yeah, I saw the errors prop up a bit more often in other projects too.

I'll see about fixing that injection method, so it doesn't throw errors anymore at least.

Hi!
Any news?

@pixeldesu
Copy link
Owner

Okay, so an update on this:

First, I have made new releases since:

6.0.1 fixed an issue with function method injections, these should work again (important for Webpack v3 and earlier).

6.1.0 introduces a new feature: Entrypoint detection 🎉

In case of WhatsApp Web, the entrypoint isn't called webpackJsonp but webpackChunkwhatsapp_web_client and moduleRaid now will try it's best to automatically detect an endpoint if webpackJsonp is not the correct one.

You can now also specify a strict option in the constructor, where detection is not run, and if your specified entrypoint (or by default webpackJsonp) is not found, you will get an error.

I also fixed the final brute-force injection method so that it doesn't say window[this.entrypoint] is not a function, but it will actually return Unknown Webpack structure instead.

This hopefully should solve most of the issues from this thread!

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

No branches or pull requests

4 participants