Reputation: 174
i am new to electron js and i created a simple app that opens whatsapp web.
First it works perfectly but i dont have chromium at that time. Then i use electron forge so i created a new app with the same code and i have chromium this time.
link for the code is here => https://github.com/gowtham758550/WA-opener
Is chrome needed or chromium is ok for running a electron app
i am a beginner help me to solve this
Upvotes: 2
Views: 352
Reputation: 5322
You need to change the user-agent.
A user-agent is just a string that Whatsapp uses to detect what OS and browser you're coming from. Currently the user-agent looks like this:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) wa-opener/1.0.0 Chrome/89.0.4389.90 Electron/12.0.2 Safari/537.36
Notice how Electron adds wa-opener/1.0.0
?
Taking wa-opener/1.0.0
out of the user-agent fixes it.
We can change the user-agent with this code:
var session = require('electron').session;
session.defaultSession.webRequest.onBeforeSendHeaders(function (detailsObj, callbackFunc) {
detailsObj.requestHeaders['User-Agent'] = detailsObj.requestHeaders['User-Agent'].replace(/wa-opener\/[.0-9]+ /, '');
callbackFunc({requestHeaders: detailsObj.requestHeaders});
});
That'll take wa-opener/1.0.0
out of the user-agent and voila!
Upvotes: 1