Skip to content

Commit

Permalink
Use userAgentFallback for userAgent injection (PR nativefier#1316)
Browse files Browse the repository at this point in the history
Per the suggestion of @fireflinchdev , this seems to alleviate our issues with things like nuking service workers for WhatsApp. The core reason being those service workers were getting the original userAgent, and not the override (if specified). This PR should fix that.

So it should resolve nativefier#1312 nativefier#719 and hopefully a few future issues as this seems to come up frequently.
  • Loading branch information
TheCleric authored Nov 29, 2021
1 parent b9c5e2b commit 5f02f14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 0 additions & 4 deletions app/src/helpers/windowEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ export function setupNativefierWindow(
options: WindowOptions,
window: BrowserWindow,
): void {
if (options.userAgent) {
window.webContents.userAgent = options.userAgent;
}

if (options.proxyRules) {
setProxyRules(window, options.proxyRules);
}
Expand Down
14 changes: 9 additions & 5 deletions app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ if (appArgs.portable) {
}

if (!appArgs.userAgentHonest) {
app.userAgentFallback = removeUserAgentSpecifics(
app.userAgentFallback,
app.getName(),
app.getVersion(),
);
if (appArgs.userAgent) {
app.userAgentFallback = appArgs.userAgent;
} else {
app.userAgentFallback = removeUserAgentSpecifics(
app.userAgentFallback,
app.getName(),
app.getVersion(),
);
}
}

// Take in a URL on the command line as an override
Expand Down

0 comments on commit 5f02f14

Please sign in to comment.