mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.04k stars 795 forks source link

Electron: WhatsApp works with Google Chrome 36+ #516

Closed geek4teck closed 5 years ago

geek4teck commented 5 years ago

Recently this error is coming up with JS file, earlier it was working fine for couple of months.

Uncaught ReferenceError: webpackJsonp is not defined

Anyone has any idea if Whatsapp has changed it's JS/Library?

geek4teck commented 5 years ago

image

group2tts commented 5 years ago

You have everything written. Upgrade your browser to version 36+

geek4teck commented 5 years ago

Chrome version is 66.

I have read other WhatsApp applications on github like franz and all of them seem to have this problem recently.

Looks like some browser detection issue.

On Tue 4 Dec, 2018, 12:49 group2tts <notifications@github.com wrote:

You have everything written. Upgrade your browser to version 36+

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/516#issuecomment-443997051, or mute the thread https://github.com/notifications/unsubscribe-auth/ATldJ96ulxJy1imrXxawWPjUCw9m_K0Gks5u1iILgaJpZM4Y_2Bj .

group2tts commented 5 years ago

You have somewhere substituted your useragent

geek4teck commented 5 years ago

I didn't change anything. Just that nodeintegration is true and websecurity is turned off.

Everything was functional last week but surprisingly not anymore.

On Tue 4 Dec, 2018, 13:11 group2tts <notifications@github.com wrote:

You have somewhere substituted your useragent

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/516#issuecomment-444001757, or mute the thread https://github.com/notifications/unsubscribe-auth/ATldJ3LtboTGl6m9Umdte3jBInu2emSAks5u1ickgaJpZM4Y_2Bj .

group2tts commented 5 years ago

Try installing the latest version Chrome.

geek4teck commented 5 years ago

It was chrome 65 and electron 2

I uninistalled electron

npm uninstall electron -g --save and reinstalled

npm install electron -g then i checked versions, it was electron 3 now and Chrome 66

Problem is still the same :-(

geek4teck commented 5 years ago

This is another example of same problem faced by other whatsapp web library users.

geek4teck commented 5 years ago

Trying to change agent, will post my findings if any success.

On Sun 9 Dec, 2018, 17:58 Beto <notifications@github.com wrote:

Hello

any solution to this problem?

Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/516#issuecomment-445533435, or mute the thread https://github.com/notifications/unsubscribe-auth/ATldJw4sQZjcRydK1SSwrPnLhuYH1g1Bks5u3QHegaJpZM4Y_2Bj .

geek4teck commented 5 years ago

I tried setting agent onbeforeSendHeaders which seem to be able to setHeaders but problem is intact :-(

session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
      details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36';
      callback({ cancel: false, requestHeaders: details.requestHeaders });
    });
geek4teck commented 5 years ago

Couldn't find a solution yet.

Please help if anyone has found a solution?

On Mon 10 Dec, 2018, 21:07 Beto <notifications@github.com wrote:

I did not understand your last post Does that mean it will not work?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/516#issuecomment-445859262, or mute the thread https://github.com/notifications/unsubscribe-auth/ATldJyV41HkIu--WVuggfa2rxZCTJbJAks5u3n_QgaJpZM4Y_2Bj .

ahccosta commented 5 years ago

Hello.

I am having the same problem, also started to occur a few days ago, after synchronizing the qrcode, it works but, its me restarting the service it presents the chrome update problem. When I remove the chromium session files it works again, but that way I always have to synchronize the QR. I'm looking for the solution too.

dev-bitrix commented 5 years ago

solved this problem read here https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/519

iarossi commented 5 years ago

Hello,

Here it just stopped happening when I added the code below:

edit: ### wapi.js https://github.com/mukulhase/WebWhatsapp-Wrapper/blob/master/webwhatsapi/js/wapi.js

add in first line:

navigator.serviceWorker.getRegistrations().then(
   function(registrations) {
       for(let registration of registrations) {
           registration.unregister();
       window.location.reload();
       }
});

I had already fix header and installed the chromium-chromium-chromedriver package for ubuntu

geek4teck commented 5 years ago

It's not working for me too:-(

On Wed 12 Dec, 2018, 22:44 Beto <notifications@github.com wrote:

Not work

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/516#issuecomment-446667519, or mute the thread https://github.com/notifications/unsubscribe-auth/ATldJyILNGadh7MqXrBW9frhpFefeuXfks5u4TljgaJpZM4Y_2Bj .

dev-bitrix commented 5 years ago

nothing to do for fixing in wapi.js just change user-agent to

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36

and will work all again

geek4teck commented 5 years ago

doesn't seem to work for me, here is the code

mainWindow = new BrowserWindow({ width: 600, height: 651, visible: true,  webPreferences: {
        nodeIntegration: true,
        partition: "persist:main",
    webSecurity:false
    }})
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { 
        details.requestHeaders["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"; 
        callback({ cancel: false, requestHeaders: details.requestHeaders }); 
    });
    mainWindow.loadURL("https://web.whatsapp.com",{userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'});
Gilkos commented 5 years ago

here the solution: function createWindow () { win = new BrowserWindow({width: 800, height: 600}); win.loadURL('http://www.whoishostingthis.com/tools/user-agent/', {userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'});

win.on('closed', () => { win = null }); }

geek4teck commented 5 years ago

here the solution: function createWindow () { win = new BrowserWindow({width: 800, height: 600}); win.loadURL('http://www.whoishostingthis.com/tools/user-agent/', {userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'});

win.on('closed', () => { win = null }); }

This works perfect for me.

All that was needed was clearing data completely (Once) and then adding these lines to switch User Agent.

raffOps commented 5 years ago

doesn't seem to work for me, here is the code

mainWindow = new BrowserWindow({ width: 600, height: 651, visible: true,  webPreferences: {
        nodeIntegration: true,
        partition: "persist:main",
  webSecurity:false
    }})
session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => { 
      details.requestHeaders["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36"; 
      callback({ cancel: false, requestHeaders: details.requestHeaders }); 
  });
  mainWindow.loadURL("https://web.whatsapp.com",{userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36'});

in wapi.js i put this code?

HaNdTriX commented 5 years ago

Here is the root of the problem: https://github.com/electron/electron/issues/16196

fabionogueira commented 5 years ago

This is work for me:

mainWindow.webContents.on('dom-ready', function(e) {
        let script = `
            window.onunload = () => {

                navigator.serviceWorker.getRegistrations().then(
                    function(registrations) {
                        for(let registration of registrations) {
                            registration.unregister();
                        }
                    }
                )

            }
            `
        mainWindow.webContents.executeJavaScript(script)
    })