pixeldesu / moduleRaid

:gift: Taking apart webpackJsonp
MIT License
156 stars 45 forks source link

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

Open KaKi87 opened 2 years ago

KaKi87 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

image

pixeldesu commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 :tada:

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!