How do I tell if a user is using Brave as their browser?

后端 未结 9 690
旧巷少年郎
旧巷少年郎 2021-02-04 01:29

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 simp

9条回答
  •  心在旅途
    2021-02-04 02:16

    2020. Updated solution:

    Chrome now adds a new key to the window object: googletag, as opposed to the old one: google

    This is the working code now:

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

提交回复
热议问题