View Single Post
Old 10-31-2019, 01:24 PM  
AmateurFlix
Confirmed User
 
Industry Role:
Join Date: Jul 2004
Posts: 7,762
Anyone got a trick to distinguish Chrome from other Chromium based browsers?

I want something to affect Google Chrome users only, and I've discovered that my current user agent detection method is inadequate.

Quote:
CHROME: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
OPERA UA: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.107
For Opera, I can at least check for the presence of that 'OPR/' string; however there's a ton of browsers out there which use Chromium as the engine, and they're all different. I don't want to use an exact match for the Chrome UA string, because it's likely to change frequently.

preg_match might be an option, however I think some browser extensions can make changes to the UA, which means matching for something like ...Safari/[0-9]+\.[0-9]+$ might not identify Chrome users with browser extensions.

If the best I can do is manually identify other browsers and make exceptions for them one by one, that is an option, but I'd rather do this algorithmically if possible. It doesn't need to be perfect.

Any ideas?
__________________
AmateurFlix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote