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

TypeError: Cannot read properties of undefined (reading 'm') #2305

Open
ljj314zz opened this issue Sep 6, 2024 · 2 comments
Open

TypeError: Cannot read properties of undefined (reading 'm') #2305

ljj314zz opened this issue Sep 6, 2024 · 2 comments

Comments

@ljj314zz
Copy link

ljj314zz commented Sep 6, 2024

WA-JS Version

any version

WhatsApp Version

any

Browser Version

any

Operation System

win11

Steps to reproduce

when use in electron,After the script is injected, WPP.version can get the version number, WPP.isinjected is false, and this error will be displayed if other commands are allowed

ErrorevaluateJs: TypeError: Cannot read properties of undefined (reading 'm')
I have tried different wajs versions

  app.on("web-contents-created", (_, webContents) => {
    const scriptPath =
      "wppconnect.js";

    const scriptContent = fs.readFileSync(scriptPath, "utf8");

    webContents.on("did-finish-load", () => {
      webContents.executeJavaScript(scriptContent);
    });
}

What is expected?

can get the correct results

What is actually happening?

WPP.chat.list() and any other have no result

Any additional comments?

No response

@ljj314zz
Copy link
Author

ljj314zz commented Sep 8, 2024

The line with error is here: t.webpackRequire.m

 function p(e, r=!1) {
                let n = Object.keys(t.webpackRequire.m);
                r && (n = n.reverse());
                const o = setTimeout((()=>{
                    a(`Searching for: ${e.toString()}`)
                }
                ), 500);
                for (const r of n)
                    if (!f(r))
                        try {
                            const n = (0,
                            t.webpackRequire)(r);
                            if (e(n, r))
                                return a(`Module found: ${r} - ${e.toString()}`),
                                clearTimeout(o),
                                r
                        } catch (e) {
                            continue
                        }

@ljj314zz
Copy link
Author

ljj314zz commented Sep 9, 2024

It is confirmed that this problem occurs after using electron's WebviewTag to inject the script

window.electronIPCHandlers.onInjWaThread(() => {
const activeWebview =  document.getElementById(
    `webview-${tabStore.selectedTabId}`
  ) as WebviewTag | null;
activeWebview?.executeJavaScript(scriptContent);
}

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

1 participant