如何判断用户是否使用Brave作为浏览器?

如何判断用户是否使用Brave作为浏览器?

问题描述:

我一直在使用 Brave 浏览器( https://www.brave. com/),我无法弄清楚如何确定用户是否正在使用 Brave .我使用了一个简单的文档来输出用户代理:

I have been messing around with the Brave browser (https://www.brave.com/), an I cannot figure out how to determine how if a user is using Brave. I used a simple document to output the user agent:

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

我得到:

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

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

这对我的情况并没有真正的帮助.有谁知道如何确定在PHP或JavaScript中使用 Brave 的任何人?谢谢!

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

Kohjah Breese的解决方案无法在Android上检测Brave(例如,Chrome被检测为Brave).但是就像他说的那样:如果您在DuckDuckGo中搜索[我的用户代理人],他们将返回勇敢".然后,您可以使用Duckduckgo的API来了解他们的浏览器是否为Brave:

Kohjah Breese's solution isn't working to detect Brave on Android (e.g. Chrome is detected as Brave). But as he said "If you search DuckDuckGo for [what's my user agent] they will return Brave." Then you can use the API of Duckduckgo to know if they 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()