Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect Brave Browser #159

Open
jeynergil opened this issue Feb 15, 2021 · 9 comments
Open

Unable to detect Brave Browser #159

jeynergil opened this issue Feb 15, 2021 · 9 comments

Comments

@jeynergil
Copy link

This is an awesome package.

Can it detect Brave Browser?

Using Brave, it returned this:

BrowserInfo {name: "chrome", version: "88.0.4324", os: "Android OS", type: "browser"}
name: "chrome"
os: "Android OS"
type: "browser"
version: "88.0.4324"

Thanks!

@DamonOehlman
Copy link
Owner

@jeynergil If you can capture the user agent string I can take a look.

@jeynergil
Copy link
Author

Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.152 Mobile Safari/537.36

@dFilipkowski0131
Copy link

i dont believe it will provide your brave due to the fact that edge and brave are both chromium browsers at their base level

@DamonOehlman
Copy link
Owner

@jeynergil @dFilipkowski0131 based on that user agent string, I feel like that is definitely going to be the case. Feels like at some stage detect-browser should be returning something "less specific". I've been running Brave for the last couple of weeks for personal use, and I just looked at the user agent here on my laptop and despite running on Windows I see exactly the same user agent string.

I think the browser developers are definitely ramping up their efforts to ensure we aren't using user agent strings!

@Benibur
Copy link

Benibur commented Feb 24, 2021

you can detect Brave this way (I tested) :
(navigator.brave && await navigator.brave.isBrave() || false)
found here : https://stackoverflow.com/a/60954062

@martonlederer
Copy link

You can also make a request to https://api.duckduckgo.com/?q=useragent&format=json and that shows Brave as a user-agent

@lancesnider
Copy link

you can detect Brave this way (I tested) : (navigator.brave && await navigator.brave.isBrave() || false) found here : https://stackoverflow.com/a/60954062

I started to make a PR for this, but got stuck on testing. I can't see a way with tape to mock navigation to include navigation.brave.isBrave(). If anyone knows how to do that, I'll happily add a PR.

@DamonOehlman
Copy link
Owner

@lancesnider Thanks for having a crack at a PR. I'm thinking that the best way to deal with the various "work arounds" required to detect browsers these days might be to add a separate file into the repo that includes the various hacks. Ideally, I'd like to keep the core functionality of this module to UA sniffing even though it's very unreliable these days. The alternative is to make the module detect all browsers by default (including the various hacks required to do so) and if people want to only use the UA sniffing they can only import that function and let dead code elimination strip out the unused code from this package.

Just trying to think of the best way to structure it. Certainly having to execute async functions to detect a browser does change the game a little.

@lancesnider
Copy link

Yeah, that all makes sense.

Regarding the async, I didn't end up needing it. if(navigator.brave) worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants