Open josephMblT opened 2 months ago
Can you install the code from Github orkestral/master directly?
There was a big update to WhatsApp a couple of months ago that totally broke the WAPI insertion and Store item generation.
A new method has been devised but has not been officially release yet - so if you can try master branch here, let us know how you get on
Hi @ghayman, normally if i create a node server and I install it as a dependency, it work well, my use case is am using an electron application and i need to inject the venom as a preload script into the webview.
Hi @ghayman, I am currently needing the same thing you mentioned, I thought about extracting the WhatsApp session this way
const sessionData = await view1.webContents.executeJavaScript( new Promise((resolve, reject) => { var request = window.indexedDB.open("wawc"); request.onsuccess = function() { var db = request.result; var transaction = db.transaction(["user"], "readonly"); var objectStore = transaction.objectStore("user"); var getAllRequest = objectStore.getAll(); getAllRequest.onsuccess = function() { resolve(getAllRequest.result); }; getAllRequest.onerror = function() { reject(getAllRequest.error); }; }; request.onerror = function() { reject(request.error); }; });
);
And then inject it into venom but I don't know if it's possible
I'm not really familiar with how to use this with Electron. Does it use Chrome/Chromium browser?
Look at the latest code in master branch to see how this now does the code injection https://github.com/orkestral/venom/blob/master/src/api/whatsapp.ts : initService()
thanks for the above response, currently if am running with puppeteer, it appears that with puppeteer, wapi works well, am still trying to find out why it is not working when i code the webpack bundle of wapi and paste on the console it does not work.
am trying to figure out how the puppeteer Store gets populated
` await this.page.evaluate(() => { window['debug'] = eval("require('debug');"); console.log({code:window['__debug']});
});`
please i was able to trace the code and i know where my problem is coming from, please this
`require('__debug` i need to know were it is coming from, so i can inject it to my script,
__debug is the module that allows to access all the WhatsApp modules. (NOTE: webpack no longer exists due to WhatsApp changes - there is some backwards compatible code still in there to help when web.whatsapp.com updates in the browser)
It should be established before you try and inject wapi.js - here is venom code location src/api/whatsapp.ts: line 51
On line 60 you can see venom injecting wapi.js
@ghayman thanks for your help, i was able to have venom working as expected.
Issue
Before, I used to inject the WAPI script directly into WhatsApp Web and could successfully get messages and create listeners. However, now when I try to retrieve all contacts or perform similar operations, it fails, and I notice that the Store object is always empty. I’m unsure if others have encountered this issue. While creating a new client with a Node.js server works, my use case requires running it directly on WhatsApp Web. Can you provide any insights or solutions for this problem?
i do this by running the bundle Wapi
i get and error here
Code
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0')
when i try getting all contacts
WAPI.getAllContacts(); VM2465:1 Uncaught TypeError: Cannot read properties of undefined (reading 'map') at window.WAPI.window.WAPI.getAllContacts (:1:86008)
what i this is happening
function injectParasite() { if (window.__debug) { getStore(window.getModuleList()).finally(); } else { if ( window.webpackChunkwhatsapp_web_client && Array.isArray(window.webpackChunkwhatsapp_web_client) ) { const parasite = injectConfig.parasite; window[injectConfig.webpack].push([ [parasite], {}, async function (o) { let modules = []; for (let idx in o.m) { modules.push(o(idx)); } await getStore(modules); } ]); } } }
I try tracing the code and I noticed that
this inject parasite is been set and i don't think it is ever been called because from what I see when its been call, the Store is been populated
Please I really need help in this,
you can try by running yarn build:wapi
copy the code in the dist/lib/wapi/wapi.js and paste on the whatsapp web console and press Enter and try any WAPI function, none will work