Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 10-31-2019, 01:24 PM   #1
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
Old 10-31-2019, 01:38 PM   #2
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
Why bother? Official version have like 99% of traffic anyway.
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-31-2019, 01:43 PM   #3
AmateurFlix
Confirmed User
 
Industry Role:
Join Date: Jul 2004
Posts: 7,762
There's a ton of traffic on Silk, Opera and others. Every Amazon Kindle uses the Silk browser.
__________________
AmateurFlix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-31-2019, 01:49 PM   #4
Ferus
Bye - Left to do stuff
 
Industry Role:
Join Date: Feb 2013
Posts: 4,108
Not 100% safe:
https://stackoverflow.com/questions/...ally-vs-chrome

Dont know programming well enough to validate this for robustness
https://social.msdn.microsoft.com/Fo...webdevelopment
Ferus is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 10-31-2019, 01:57 PM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,111
Found this answer on stackoverflow, don't know if it is 100% current or not.

https://stackoverflow.com/questions/...48618#13348618

Quote:
o check if browser is Google Chrome, try this:

// please note,
// that IE11 now returns undefined again for window.chrome
// and new Opera 30 outputs true for window.chrome
// but needs to check if window.opr is not undefined
// and new IE Edge outputs to true now for window.chrome
// and if not iOS Chrome check
// so use the below updated condition
var isChromium = window.chrome;
var winNav = window.navigator;
var vendorName = winNav.vendor;
var isOpera = typeof window.opr !== "undefined";
var isIEedge = winNav.userAgent.indexOf("Edge") > -1;
var isIOSChrome = winNav.userAgent.match("CriOS");

if (isIOSChrome) {
// is Google Chrome on IOS
} else if(
isChromium !== null &&
typeof isChromium !== "undefined" &&
vendorName === "Google Inc." &&
isOpera === false &&
isIEedge === false
) {
// is Google Chrome
} else {
// not Google Chrome
}
Example of use: Attention Required! | Cloudflare

The reason this works is because if you use the Google Chrome inspector and go to the console tab. Type 'window' and press enter. Then you be able to view the DOM properties for the 'window object'. When you collapse the object you can view all the properties, including the 'chrome' property.

You can't use strictly equals true anymore to check in IE for window.chrome. IE used to return undefined, now it returns true. But guess what, IE11 now returns undefined again. IE11 also returns a empty string "" for window.navigator.vendor.

I hope this helps!

UPDATE:

Thank you to Halcyon991 for pointing out below, that the new Opera 18+ also outputs to true for window.chrome. Looks like Opera 18 is based on Chromium 31. So I added a check to make sure the window.navigator.vendor is: "Google Inc" and not is "Opera Software ASA". Also thanks to Ring and Adrien Be for the heads up about Chrome 33 not returning true anymore... window.chrome now checks if not null. But play close attention to IE11, I added the check back for undefined since IE11 now outputs undefined, like it did when first released.. then after some update builds it outputted to true .. now recent update build is outputting undefined again. Microsoft can't make up it's mind!

UPDATE 7/24/2015 - addition for Opera check

Opera 30 was just released. It no longer outputs window.opera. And also window.chrome outputs to true in the new Opera 30. So you must check if OPR is in the userAgent. I updated my condition above to account for this new change in Opera 30, since it uses same render engine as Google Chrome.

UPDATE 10/13/2015 - addition for IE check

Added check for IE Edge due to it outputting true for window.chrome .. even though IE11 outputs undefined for window.chrome. Thanks to artfulhacker for letting us know about this!

UPDATE 2/5/2016 - addition for iOS Chrome check

Added check for iOS Chrome check CriOS due to it outputting true for Chrome on iOS. Thanks to xinthose for letting us know about this!

UPDATE 4/18/2018 - change for Opera check

Edited check for Opera, checking window.opr is not undefined since now Chrome 66 has OPR in window.navigator.vendor. Thanks to Frosty Z and Daniel Wallman for reporting this!
.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 11-01-2019, 07:06 AM   #6
AmateurFlix
Confirmed User
 
Industry Role:
Join Date: Jul 2004
Posts: 7,762
Thanks guys!
__________________
AmateurFlix is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
chrome, browsers, gecko, x64, win64;, applewebkit/537.36, khtml, safari/537.36, opera, identify, extensions, browser, 6.1;, option, chromium, users, windows, mozilla/5.0, means, matching, safari/[0-9]+.[0-9]+$, perfect, preg_match, frequently, ideas



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.