Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Improve user agent handling/provide user agent "short" codes #1198

Merged
merged 12 commits into from May 22, 2021

Conversation

TheCleric
Copy link
Collaborator

@TheCleric TheCleric commented May 20, 2021

So I took a risk with this PR (and probably should have discussed some of this with you first @ronjouch, but I started tugging on the thread of:

How can I get Google (and other apps) to behave better or make it easier for a user to be self-sufficient?

Obviously this has been an ongoing problem, but particularly in this thread, and this comment: #1193 (comment) . Not that there was anything WRONG in this question, it just got me thinking that there has to be a better way.

So this is my attempt at a "better" way. Better being in the eye of the developer though, I'm fine changing some of this until we're both happy.

Here's what I've changed:

  • Eliminated the "inferUserAgent" logic, because I realized we can:
  • Rely more heavily on Electron's app.userAgentFallback which has a Chrome-like user agent pre-populated in it already, based on the Electron version used. For --honest/--user-agent-honest we'll use it as is. Without that we'll strip out the elements of it that indicate it's not Chrome (Electron/version and GeneratedAppName/version)
  • Add short codes that can be passed to --user-agent that will determine the latest versions of some common browsers, and generate a user agent for the user, so they don't have to go hunting one down. Included is support for:
    • edge which will grab the chrome version by electron version like inferUserAgent did, and populate it
    • firefox which will hit the FF versions API and get latest stable and generate a user agent
    • safari which will hit Wikipedia (sorry, it's the only reliable, up to date source I could find) and get the latest version (and WebKit version) and generate a user agent
  • Standardize on using userAgentHonest over honest

@TheCleric TheCleric requested a review from ronjouch May 20, 2021 15:13
Copy link
Contributor

@ronjouch ronjouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have a couple nits.

"Add short codes [so that users] don't have to go hunting one down"

Great idea 👍

app/src/main.ts Outdated Show resolved Hide resolved
src/infer/browsers/inferFirefoxVersion.ts Show resolved Hide resolved
src/infer/browsers/inferFirefoxVersion.ts Outdated Show resolved Hide resolved
src/infer/browsers/inferFirefoxVersion.ts Outdated Show resolved Hide resolved
src/infer/browsers/inferSafariVersion.ts Show resolved Hide resolved
docs/api.md Outdated Show resolved Hide resolved
@TheCleric
Copy link
Collaborator Author

Alright @ronjouch I think all nits have been addressed

Copy link
Contributor

@ronjouch ronjouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍:clap:

@TheCleric TheCleric merged commit d6730f7 into nativefier:master May 22, 2021
Adam777Z pushed a commit to Adam777Z/nativefier that referenced this pull request Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants