本文介绍了如何判断用户是否使用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>

我得到:

这对我的情况并没有真正的帮助.有谁知道如何确定在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()

这篇关于如何判断用户是否使用Brave作为浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 17:50
查看更多