From 897eb45aec2330e7566c48c9e54192aae84bd8e9 Mon Sep 17 00:00:00 2001 From: Kyle Kizirian Date: Mon, 2 Aug 2021 13:53:12 -0400 Subject: [PATCH 1/2] Add additional WebKit browsers Add support for the following: - Coc Coc Browser - Headless Chrome - iOS WebViews --- CHANGELOG.md | 3 +++ all_test.go | 15 +++++++++++++++ browser.go | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90730fe..cbe027b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ - Fix detection of Linux ARM-based Android. See [3b0e113c8047](https://github.com/mssola/user_agent/commit/3b0e113c804708c01de00c27aae07d2acfee40d8). - Add detection of Chromium Edge on Windows. See [ea81f1e9d61c](https://github.com/mssola/user_agent/commit/ea81f1e9d61c094df4156690a8f4d5481b0d6c4a). - Add detection of OkHttp. See [6b33e248e796](https://github.com/mssola/user_agent/commit/6b33e248e7969cf3e76128a34d33be88d4eb0dc8). +- Add detection of Coc Coc Browser. +- Add detection of Headless Chrome. +- Add detection of iOS WebViews. ## 0.5.2 diff --git a/all_test.go b/all_test.go index 3480110..51286ff 100644 --- a/all_test.go +++ b/all_test.go @@ -471,6 +471,11 @@ var uastrings = []struct { expected: "Mozilla:5.0 Platform:Macintosh OS:Intel Mac OS X 10_6_5 Localization:en-US Browser:Chrome-8.0.552.231 Engine:AppleWebKit-534.10 Bot:false Mobile:false", expectedOS: &OSInfo{"Intel Mac OS X 10_6_5", "Mac OS X", "10.6.5"}, }, + { + title: "Headless Chrome", + ua: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/92.0.4515.107 Safari/537.36", + expected: "Mozilla:5.0 Platform:X11 OS:Linux x86_64 Browser:Headless Chrome-92.0.4515.107 Engine:AppleWebKit-537.36 Bot:false Mobile:false", + }, { title: "SafariMac", ua: "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16", @@ -594,6 +599,16 @@ var uastrings = []struct { ua: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) CozyDrive/3.17.0 Chrome/73.0.3683.119 Electron/5.0.0 Safari/537.36", expected: "Mozilla:5.0 Platform:Windows OS:Windows 10 Browser:Electron-5.0.0 Engine:AppleWebKit-537.36 Bot:false Mobile:false", }, + { + title: "Coc Coc", + ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) coc_coc_browser/96.0.230 Chrome/90.0.4430.230 Safari/537.36", + expected: "Mozilla:5.0 Platform:Macintosh OS:Intel Mac OS X 10_15_7 Browser:Coc Coc-96.0.230 Engine:AppleWebKit-537.36 Bot:false Mobile:false", + }, + { + title: "LinkedInApp", + ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 [LinkedInApp]", + expected: "Mozilla:5.0 Platform:iPhone OS:CPU iPhone OS 14_6 like Mac OS X Browser:Mobile App Engine:AppleWebKit-605.1.15 Bot:false Mobile:true", + }, // Dalvik { diff --git a/browser.go b/browser.go index a31815d..10c63c9 100644 --- a/browser.go +++ b/browser.go @@ -82,11 +82,18 @@ func (p *UserAgent) detectBrowser(sections []section) { case "OPR": p.browser.Name = "Opera" p.browser.Version = sections[slen-1].version + case "Mobile": + p.browser.Name = "Mobile App" + p.browser.Version = "" default: switch sections[slen-3].name { case "YaBrowser": p.browser.Name = "YaBrowser" p.browser.Version = sections[slen-3].version + case "coc_cow_browser": + case "coc_coc_browser": + p.browser.Name = "Coc Coc" + p.browser.Version = sections[slen-3].version default: switch sections[slen-2].name { case "Electron": @@ -96,6 +103,8 @@ func (p *UserAgent) detectBrowser(sections []section) { switch sections[sectionIndex].name { case "Chrome", "CriOS": p.browser.Name = "Chrome" + case "HeadlessChrome": + p.browser.Name = "Headless Chrome" case "Chromium": p.browser.Name = "Chromium" case "FxiOS": From 38935c159dbed88d65ef959572d0f9bbd131d465 Mon Sep 17 00:00:00 2001 From: Kyle Kizirian Date: Mon, 2 Aug 2021 18:14:39 -0400 Subject: [PATCH 2/2] Add support for DuckDuckGo and GoogleApp on iOS --- all_test.go | 10 ++++++++++ browser.go | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/all_test.go b/all_test.go index 51286ff..f6be56c 100644 --- a/all_test.go +++ b/all_test.go @@ -609,6 +609,16 @@ var uastrings = []struct { ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 [LinkedInApp]", expected: "Mozilla:5.0 Platform:iPhone OS:CPU iPhone OS 14_6 like Mac OS X Browser:Mobile App Engine:AppleWebKit-605.1.15 Bot:false Mobile:true", }, + { + title: "Google App for iOS", + ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/170.0.386351093 Mobile/15E148 Safari/604.1", + expected: "Mozilla:5.0 Platform:iPhone OS:CPU iPhone OS 14_1 like Mac OS X Browser:Google App-170.0.386351093 Engine:AppleWebKit-605.1.15 Bot:false Mobile:true", + }, + { + title: "DuckDuckGo Browser for iOS", + ua: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.6 Mobile/15E148 DuckDuckGo/7 Safari/605.1.15", + expected: "Mozilla:5.0 Platform:iPhone OS:CPU iPhone OS 14_6 like Mac OS X Browser:DuckDuckGo-7 Engine:AppleWebKit-605.1.15 Bot:false Mobile:true", + }, // Dalvik { diff --git a/browser.go b/browser.go index 10c63c9..afff66b 100644 --- a/browser.go +++ b/browser.go @@ -90,7 +90,6 @@ func (p *UserAgent) detectBrowser(sections []section) { case "YaBrowser": p.browser.Name = "YaBrowser" p.browser.Version = sections[slen-3].version - case "coc_cow_browser": case "coc_coc_browser": p.browser.Name = "Coc Coc" p.browser.Version = sections[slen-3].version @@ -99,6 +98,9 @@ func (p *UserAgent) detectBrowser(sections []section) { case "Electron": p.browser.Name = "Electron" p.browser.Version = sections[slen-2].version + case "DuckDuckGo": + p.browser.Name = "DuckDuckGo" + p.browser.Version = sections[slen-2].version default: switch sections[sectionIndex].name { case "Chrome", "CriOS": @@ -107,6 +109,8 @@ func (p *UserAgent) detectBrowser(sections []section) { p.browser.Name = "Headless Chrome" case "Chromium": p.browser.Name = "Chromium" + case "GSA": + p.browser.Name = "Google App" case "FxiOS": p.browser.Name = "Firefox" default: