Open jeynergil opened 3 years ago
@jeynergil If you can capture the user agent string I can take a look.
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
i dont believe it will provide your brave due to the fact that edge and brave are both chromium browsers at their base level
@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!
you can detect Brave this way (I tested) :
(navigator.brave && await navigator.brave.isBrave() || false)
found here : https://stackoverflow.com/a/60954062
You can also make a request to https://api.duckduckgo.com/?q=useragent&format=json
and that shows Brave as a user-agent
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.
@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.
Yeah, that all makes sense.
Regarding the async, I didn't end up needing it. if(navigator.brave)
worked fine.
This is an awesome package.
Can it detect Brave Browser?
Using Brave, it returned this:
Thanks!