You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 29, 2023. It is now read-only.
WhatsApp Web stopped working around 2018-11-30 - Asks for Google Chrome ≥ 36 #719
Full nativefier command used to build your app: nativefier --name "WhatsApp Web" https://web.whatsapp.com
Version of Nativefier (run nativefier --version): v7.6.8
Version of node.js (run node --version): v8.10.0
OS: Ubuntu 18.04.1 LTS - Bionic
Error message / stack trace (if any): None.
Reacted by Rocco Musolino, Shah Rukh Khan, barakt, kolaente, ender, Luís de Sousa, ugurozturk, Sparsa, Vittorio, Daniel Thaagaard Andreasen and 7 more
@coolboi567 just update Nativefier and re-package the app. Yes we know we should do a better job at communicating this to users, see #556; contributions welcome.
@bitlab-code Nativefier 7.6.8 ships with a default Electron version of 3.0.3, based on Chrome 66. Are you sure you did re-package your app with it, by re-running the nativefier command used to package it? If yes, then inside your nativefied app can you pop open the inspector (Ctrl/Cmd+Shift+I) and in the console type navigator.userAgent . What does it output?
changed the title [-]WhatsApp Web stopped working - Asks for G-chrome update[/-][+]WhatsApp Web stopped working around 2018-11-10 - Asks for Google Chrome ≥ 36[/+]on Nov 30, 2018
changed the title [-]WhatsApp Web stopped working around 2018-11-10 - Asks for Google Chrome ≥ 36[/-][+]WhatsApp Web stopped working around 2018-11-30 - Asks for Google Chrome ≥ 36[/+]on Dec 2, 2018
Reacted by Andrei Shevchuk, Prashant Shahi, Alexandre Cardim, Pedro Javier Nicolás, Ricardo Fuhrmann, Rocco Musolino, Moritz Beck, Fabio, SeerLite, Robert von Burg and 19 more
Reacted by Eray Erdin (&mut self)
Reacted by Alexandre Cardim, Ricardo Fuhrmann, Vittorio, MrJianlucah, Fabio, SeerLite, timching, Vagner Kaefer, originaltebas, Richard Steinmetz and 8 more
/* site.css *//* header is draggable... */header{-webkit-app-region: drag;}/* but any buttons inside the header shouldn't be draggable */headerbutton{-webkit-app-region: no-drag;}/* perhaps move some items out of way for the traffic light */#sideheader>div:first-of-type{margin-left:75px;}
Reacted by Ash Berlin-Taylor, Jseeca, Fernando De Lucchi and Just Patrick
The injection code to make whatsapp work in a nativefier app recently stopped working for me as well.
However, in case anyone else has the same issue, here is my workaround/new injection js (somewhat more reliable then the previous one?):
// unregister serviceworker after startup -> don't interfere at next startupletdeleteFun=function(){if("serviceWorker"innavigator){navigator.serviceWorker.getRegistrations().then(function(e){//console.log(e);for(rofe){r.unregister();}});}};deleteFun();setInterval(deleteFun,1000);
It might be a good idea to include it in future releases of the package if more people have this issue.
EDIT: just noticed that this is very close to @aarestu s code. Leaving this for increased diversity...
UPDATE: deregistering every time (even if there is no message informing you about the chrome version) makes restarting after newly opening the app unnecessary. Hence a merged/improved version of @aarestu s code below
log is not defined, so the code never goes to require(jsFile). Instead all you get is:
VM1776 preload.js:84 Uncaught ReferenceError: log is not defined
at injectScripts (VM1776 preload.js:84)
at HTMLDocument.<anonymous> (VM1776 preload.js:29)
For full context, here's the preload.js as seen by me:
(function(exports,require,module,__filename,__dirname,process,global,Buffer){returnfunction(exports,require,module,__filename,__dirname){"use strict";var__createBinding=(this&&this.__createBinding)||(Object.create ? (function(o,m,k,k2){if(k2===undefined)k2=k;Object.defineProperty(o,k2,{enumerable: true,get: function(){returnm[k];}});}) : (function(o,m,k,k2){if(k2===undefined)k2=k;o[k2]=m[k];}));var__setModuleDefault=(this&&this.__setModuleDefault)||(Object.create ? (function(o,v){Object.defineProperty(o,"default",{enumerable: true,value: v});}) : function(o,v){o["default"]=v;});var__importStar=(this&&this.__importStar)||function(mod){if(mod&&mod.__esModule)returnmod;varresult={};if(mod!=null)for(varkinmod)if(k!=="default"&&Object.prototype.hasOwnProperty.call(mod,k))__createBinding(result,mod,k);__setModuleDefault(result,mod);returnresult;};Object.defineProperty(exports,"__esModule",{value: true});exports.INJECT_DIR=void0;/** * Preload file that will be executed in the renderer process. * Note: This needs to be attached **prior to imports**, as imports * would delay the attachment till after the event has been raised. */document.addEventListener('DOMContentLoaded',()=>{injectScripts();// eslint-disable-line @typescript-eslint/no-use-before-define});constfs=__importStar(require("fs"));constpath=__importStar(require("path"));constelectron_1=require("electron");// Do *NOT* add 3rd-party imports here in preload (except for webpack `externals` like electron).// They will work during development, but break in the prod build :-/ .// Electron doc isn't explicit about that, so maybe *we*'re doing something wrong.// At any rate, that's what we have now. If you want an import here, go ahead, but// verify that apps built with a non-devbuild nativefier (installed from tarball) work.// Recipe to monkey around this, assuming you git-cloned nativefier in /opt/nativefier/ :// cd /opt/nativefier/ && rm -f nativefier-43.1.0.tgz && npm run build && npm pack && mkdir -p ~/n4310/ && cd ~/n4310/ \// && rm -rf ./* && npm i /opt/nativefier/nativefier-43.1.0.tgz && ./node_modules/.bin/nativefier 'google.com'// See https://github.com/nativefier/nativefier/issues/1175// and https://www.electronjs.org/docs/api/browser-window#new-browserwindowoptions / preloadexports.INJECT_DIR=path.join(__dirname,'..','inject');/** * Patches window.Notification to: * - set a callback on a new Notification * - set a callback for clicks on notifications * @param createCallback * @param clickCallback */functionsetNotificationCallback(createCallback,clickCallback){constOldNotify=window.Notification;constnewNotify=function(title,opt){createCallback(title,opt);constinstance=newOldNotify(title,opt);instance.addEventListener('click',clickCallback);returninstance;};newNotify.requestPermission=OldNotify.requestPermission.bind(OldNotify);Object.defineProperty(newNotify,'permission',{get: ()=>OldNotify.permission,});// @ts-expect-error TypeScript says its not compatible, but it works?window.Notification=newNotify;}functioninjectScripts(){constneedToInject=fs.existsSync(exports.INJECT_DIR);if(!needToInject){return;}// Dynamically require scriptstry{constjsFiles=fs.readdirSync(exports.INJECT_DIR,{withFileTypes: true}).filter((injectFile)=>injectFile.isFile()&&injectFile.name.endsWith('.js')).map((jsFileStat)=>path.join('..','inject',jsFileStat.name));for(constjsFileofjsFiles){log.debug('Injecting JS file',jsFile);require(jsFile);}}catch(err){log.error('Error encoutered injecting JS files',err);}}functionnotifyNotificationCreate(title,opt){electron_1.ipcRenderer.send('notification',title,opt);}functionnotifyNotificationClick(){electron_1.ipcRenderer.send('notification-click');}// @ts-expect-error TypeScript thinks these are incompatible but they aren'tsetNotificationCallback(notifyNotificationCreate,notifyNotificationClick);electron_1.ipcRenderer.on('params',(event,message)=>{log.debug('ipcRenderer.params',{ event, message });constappArgs=JSON.parse(message);log.info('nativefier.json',appArgs);});electron_1.ipcRenderer.on('debug',(event,message)=>{log.debug('ipcRenderer.debug',{ event, message });});//# sourceMappingURL=preload.js.map}.call(this,exports,require,module,__filename,__dirname);});
@Nowaker, I agree with your assessment. Not sure what is causing that log definition to be missing as we added that 4 months ago (and looking through the Arch deps, they should be on a version that includes it). We could add a workaround, but my fear would be that somehow that code wouldn't make it upstream just as the const log = console; does not.
I have no idea about JavaScript or if this doesn't break something half-important, but the app seems to work for me now.
The nativefier app wouldn't load at all back then (due to this), and this magic line is what made it all work. I'm glad that this isn't needed anymore and that this was looked at by somebody who actually knows what they're doing.
For me only code snippet from nielstron comment worked using safari user agent. Anything else just fails, including code snippet on main README.md page.
Activity
ronjouch commentedon Nov 30, 2018
@coolboi567 just update Nativefier and re-package the app. Yes we know we should do a better job at communicating this to users, see #556; contributions welcome.
bitlab-code commentedon Nov 30, 2018
same issue with vers. 7.6.8
I think this issue need to be open
ronjouch commentedon Nov 30, 2018
@bitlab-code Nativefier 7.6.8 ships with a default Electron version of 3.0.3, based on Chrome 66. Are you sure you did re-package your app with it, by re-running the nativefier command used to package it? If yes, then inside your nativefied app can you pop open the inspector (Ctrl/Cmd+Shift+I) and in the console type
navigator.userAgent. What does it output?bitlab-code commentedon Nov 30, 2018
@ronjouch command + log

ronjouch commentedon Nov 30, 2018
@bitlab-code thanks, your setup looks good indeed.
WhatsApp must be doing some kind of new userAgent sniffing / feature detection that results in blocking Nativefier. Patches welcome.
[-]WhatsApp Web stopped working - Asks for G-chrome update[/-][+]WhatsApp Web stopped working around 2018-11-10 - Asks for Google Chrome ≥ 36[/+][-]WhatsApp Web stopped working around 2018-11-10 - Asks for Google Chrome ≥ 36[/-][+]WhatsApp Web stopped working around 2018-11-30 - Asks for Google Chrome ≥ 36[/+]lima-eduardo commentedon Dec 2, 2018
As a "workaround" you can go to 'edit > clear app data' and rescan the QR code.
saulocastelo commentedon Dec 3, 2018
Better "workaround"
Steps:
Or inject this code
lipe1966 commentedon Dec 11, 2018
sorry for the noob question.
Where should i Inject the above code?
vip9 commentedon Dec 11, 2018
"Bypass for network" works for me only once.
65 remaining items
renyhp commentedon Oct 21, 2020
Is there a way to inject the code without building the app again?
EDIT: Yes, there is. Simply insert @aarestu's code in
resources/app/inject/inject.js.cr3ative commentedon Jun 14, 2021
I just had to "get around" this and it's working fine with the "safari" user agent setting. Here's my build command:
whatsapp.css:
nielstron commentedon Aug 8, 2021
The injection code to make whatsapp work in a nativefier app recently stopped working for me as well.
However, in case anyone else has the same issue, here is my workaround/new injection js (somewhat more reliable then the previous one?):
(already in https://github.com/nielstron/ubuntu.whatsapp-nativefier)
It might be a good idea to include it in future releases of the package if more people have this issue.
EDIT: just noticed that this is very close to @aarestu s code. Leaving this for increased diversity...
UPDATE: deregistering every time (even if there is no message informing you about the chrome version) makes restarting after newly opening the app unnecessary. Hence a merged/improved version of @aarestu s code below
Nowaker commentedon Sep 29, 2021
The problem with Whatsapp is caused by Nativefier, not the injection code we use to make it work. Nativefier fails to correctly load the inject code.
Uncaught ReferenceError: log is not definedfrom https://github.com/nativefier/nativefier/blob/master/app/src/preload.ts#L78logis not defined, so the code never goes torequire(jsFile). Instead all you get is:I don't know why
logis undefined - especially givenconst log = console;in the Typescript source - but the nativefied WhatsApp from https://aur.archlinux.org/packages/whatsapp-nativefier is broken for this reason.For full context, here's the
preload.jsas seen by me:TheCleric commentedon Sep 29, 2021
@Nowaker, I agree with your assessment. Not sure what is causing that log definition to be missing as we added that 4 months ago (and looking through the Arch deps, they should be on a version that includes it). We could add a workaround, but my fear would be that somehow that code wouldn't make it upstream just as the
const log = console;does not.Nowaker commentedon Sep 29, 2021
Let's find out why
logis undefined. PKGBUILD fornodejs-nativefierdoesn't do anything crazy. It purely uses your project, without modifications:I've just built the latest version, 45.0.4, just to make sure.
But still no change.

logis still undefined:Nowaker commentedon Sep 29, 2021
Okay... I've spotted something silly in Whatsapp's PKGBUILD.
sed -i -e "/loglevel/d" "${srcdir}/${_folder}/resources/app/lib/preload.js"This removes the line that is very required... Checking it now.
Nowaker commentedon Sep 29, 2021
Yeah, that fixes the problem. Not sure why it was there. Submitting a patch to the PKGBUILD.
inject.js: use @nielstron's version
lighterowl commentedon Oct 23, 2021
I introduced this back in March 2020 with the following comment in the AUR :
The nativefier app wouldn't load at all back then (due to this), and this magic line is what made it all work. I'm glad that this isn't needed anymore and that this was looked at by somebody who actually knows what they're doing.
kem-a commentedon Nov 12, 2021
For me only code snippet from nielstron comment worked using safari user agent. Anything else just fails, including code snippet on main README.md page.
Use userAgentFallback for userAgent injection (PR #1316)
Use userAgentFallback for userAgent injection (PR nativefier#1316)