How do I know if a user uses Braves as their browser?

I mixed in with the Brave browser ( https://www.brave.com/ ), I can’t figure out how to determine how a user is using Brave. I used a simple document to display a user agent:

<script>document.write(navigator.userAgent);</script> 

and I get:

Mozilla / 5.0 (Windows NT 10.0; Win64; x64) AppleWebKit / 537.36 (KHTML, e.g. Gecko) Chrome / 49.0.2623.108 Safari / 537.36

which doesn't really help me in my situation. Does anyone know how to identify someone using Brave in PHP or JavaScript? Thanks!

+10
source share
5 answers

The “brave” in the user agent has been removed in version 0.9.

From changelog :

Removed Brave from the User Agent HTTP header to reduce fingerprinting.

+11
source

Brave has the same user agent as Chrome. But Chrome itself adds a lot (currently 1768) of the Chrome-specific properties to the window object. One of them is window.google. So finding the Brave is pretty simple (for now):

 const ua = window.navigator.userAgent.toLowerCase(); const isChrome = /chrome|crios/.test(ua) && ! /edge|opr\//.test(ua) const isBrave = isChrome && ! window.google; 

So boldly, lol.

+6
source

A brave appears, has several different objects in the window object. I'm not sure how adjacent they are in different versions of Brave, but I noticed two in the window.navigator object that are not displayed: plugins and mimeTypes. Since Brave is intended to be used as a browser for privacy, I think that they are likely to remain empty. So I will check to check their length.

Please note that you also need to first check if the browser is a desktop; You may not be able to detect the Brave Mobile browser; and the code below will pick up many mobile browsers

 var agent = navigator.userAgent.toLowerCase(); var isChrome = /chrome|crios/.test(agent) && ! /edge|opr\//.test(agent); var isBrave = isChrome && window.navigator.plugins.length === 0 && window.navigator.mimeTypes.length === 0; if(isBrave) console.log( isBrave ); 

If you search in DuckDuckGo [which is my user agent], they will return Brave. If you open the JS file attachments, you will find complex browser detection that Brave can detect.

+5
source

The brave one does not have its own User-Agent, as indicated in other answers. However, you can track it pretty easily to distinguish it from Google Chrome. The current release, version 0.23.19, has at least 40 unique features that set it apart from other browsers. I will talk more about this in this article . However, this is an absurd decision. Please just ask Brave to restore its own User-Agent string.

+3
source

Kohjah Breese's solution does not work to detect Brave on Android (for example, Chrome is defined as Brave). But, as he said: "If you search in DuckDuckGo [which is my user agent], they will return Brave." You can then use the Duckduckgo API to find out if their browser is Brave:

 var request = new XMLHttpRequest() request.open('GET', 'https://api.duckduckgo.com/?q=useragent&format=json', true) request.onload = function () { var data = JSON.parse(this.response) var isBrave = data['Answer'].includes('Brave'); if(isBrave){ console.log( isBrave ); } } request.send() 
0
source

All Articles