Browserino
A ruby browser (dare I say) sniffer
Install / Use
/learn @SidOfc/BrowserinoREADME
Browserino
Browserino is a tool that parses a user agent string into a convenient object to work with. This allows developers to gather information about the system of a user on a website without having to ask countless questions about their browser / OS versions.
Status
Table of Contents
<details> <summary>Click to expand Table of Contents</summary> <ul> <li><a href="#browserino">Browserino</a></li> <li><a href="#status">Status</a></li> <li><a href="#table-of-contents">Table of Contents</a></li> <li><a href="#sources">Sources</a></li> <li><a href="#changelog">Changelog</a><ul> <li><a href="#10-07-2019-version-450">10-07-2019 VERSION 4.5.0</a></li> <li><a href="#21-10-2018-version-441">21-10-2018 VERSION 4.4.1</a></li> <li><a href="#23-06-2018-version-440">23-06-2018 VERSION 4.4.0</a></li> </ul></li> <li><a href="#installation">Installation</a></li> <li><a href="#rails--320">Rails (>= 3.2.0)</a><ul> <li><a href="#initializer">Initializer</a></li> </ul></li> <li><a href="#usage">Usage</a><details><summary>show 5 items</summary><ul> <li><a href="#client">Client</a></li> <li><a href="#formatting">Formatting</a><ul> <li><a href="#non-version-like-properties">Non version-like properties</a></li> <li><a href="#version-like-properties">Version-like properties</a></li> </ul></li> <li><a href="#config">Config</a><ul> <li><a href="#matchers">Matchers</a></li> <li><a href="#aliasses">Aliasses</a></li> <li><a href="#labels">Labels</a></li> <li><a href="#http-headers">HTTP headers</a></li> </ul></details></li> <li><a href="#methods">Methods</a><details><summary>show 31 items</summary><ul> <li><a href="#name">name</a></li> <li><a href="#namesym-opts--">name?(sym, opts = {})</a></li> <li><a href="#version">version</a></li> <li><a href="#versionversion">version?(version)</a></li> <li><a href="#engine">engine</a></li> <li><a href="#enginesym-opts--">engine?(sym, opts = {})</a></li> <li><a href="#engine_version">engine_version</a></li> <li><a href="#engine_versionversion">engine_version?(version)</a></li> <li><a href="#platform">platform</a></li> <li><a href="#platformsym-opts--">platform?(sym, opts = {})</a></li> <li><a href="#platform_label">platform_label</a></li> <li><a href="#platform_version">platform_version</a></li> <li><a href="#platform_versionversion">platform_version?(version)</a></li> <li><a href="#device">device</a></li> <li><a href="#devicesym">device?(sym)</a></li> <li><a href="#architecture">architecture</a></li> <li><a href="#architecturesym">architecture?(sym)</a></li> <li><a href="#locale">locale</a></li> <li><a href="#locale-1">locale?</a></li> <li><a href="#locales">locales</a></li> <li><a href="#locales-1">locales?</a></li> <li><a href="#x64">x64?</a></li> <li><a href="#x32">x32?</a></li> <li><a href="#mobile-and-mobile">mobile and #mobile?</a></li> <li><a href="#type">type</a></li> <li><a href="#typesym">type?(sym)</a></li> <li><a href="#like">like</a></li> <li><a href="#likesym-opts--">like?(sym, opts = {})</a></li> <li><a href="#issym-opts--">is?(sym, opts = {})</a></li> <li><a href="#not">not</a></li> <li><a href="#notsym-opts--">not?(sym, opts = {})</a></li> </ul></li> <li><a href="#magic-methods">Magic methods</a><ul> <li><a href="#names">Names</a></li> <li><a href="#aliasses-1">Aliasses</a></li> </ul></li> <li><a href="#supported">Supported</a><details><summary>show 8 items</summary><ul> <li><a href="#browsers">Browsers</a></li> <li><a href="#bots">Bots</a></li> <li><a href="#validators">Validators</a></li> <li><a href="#libraries">Libraries</a></li> <li><a href="#email-clients">Email Clients</a></li> <li><a href="#rss">RSS</a></li> <li><a href="#platforms">Platforms</a><ul> <li><a href="#android">Android</a></li> <li><a href="#windows">Windows</a></li> <li><a href="#macintosh">Macintosh</a></li> </ul></li> <li><a href="#devices">Devices</a></li> </ul></li></ul></li> </ul> </details>Sources
Many thanks to the creators and maintainers of the following sources of user agents and timelines:
- udger.com
- ua.theafh.net
- user-agents.org
- zytrax.com
- useragentstring.com
- whatismybrowser.com
- mobile247.eu
- commons.wikimedia.org browser timeline
- browscap database (github repo)
Changelog
dates are in dd-mm-yyyy format older changes can be found in the changelog
10-07-2019 VERSION 4.5.0
- Add: browser user-agents
:basilisk:facebook_app
- Add:
:goannarendering engine detection - Add:
:catalinalabel for MacOS 10.15.x
21-10-2018 VERSION 4.4.1
- Fix:
Browserino.parsehandlesnilandfalseby converting them to an empty string
23-06-2018 VERSION 4.4.0
- Update: Gem dependencies
- Add: ability to supply HTTP headers to Browserino for extra information
- Improve: location will be detected from HTTP headers when available (on by default in Rails)
- Add:
prop_missingDSL for last-minute info gathering - Add: Android
:pielabel - Add:
:falkonalias for:qupzillaorange_browser - Add:
:alohabrowser - Add:
:iris - Add:
:otter - Add:
:chedot - Add:
:cm_browser - Add:
:diglo - Add:
:diigo_browser - Add:
:flyflow - Add:
:freebox - Add:
:kuaiso - Add:
:lovense - Add:
:slimjet - Add:
:zetakey - Add:
:wkbrowser - Add:
:yolobrowser - Add:
:whale - Add:
:vivo - Add:
:jasmine - Add:
:seraphic_sraf - Add:
:phantomjs - Add:
:slimerjs - Add:
:liebao - Add:
:w3m - Add:
:charon - Add:
:cent - Add:
:jig_browser_web - Add:
:blazer
Installation
Add this line to your application's Gemfile:
gem 'browserino'
And then execute:
$ bundle
Or install it yourself with:
$ gem install browserino
After installing the gem globally or in your application you'll have to require the gem before being able to use it.
require 'browserino'
Afterwards, the gem is loaded and you can proceed by calling:
Browserino.parse '<user agent>'[, {'request-header' => 'header-value', ...}]
The first argument to Browserino.parse is a user agent string. This is the string that browsers send to webservers for identification.
The second (optional) argument to Browserino.parse is a hash that contains HTTP headers. When a property could not be found, these headers
will be used by Browserino to attempt to extract it from there if a prop_missing handler is defined for it.
Browserino is tested with the following ruby versions
- 2.0.0
- 2.1.0
- 2.2.0
- 2.3.0
- 2.4.0
- 2.5.0
Rails (>= 3.2.0)
If you're using Rails (>= 3.2.0) you'll have access to a client object. Browserino will initialize itself using request.headers['User-Agent'] and will also use Rails request.headers to find
extra information that could not be found in the user agent (e.g. user locales).
A quick example on how to get going:
class ExampleController < ApplicationController
def example_method
render json: client.to_json
end
end
Initializer
If you would like to extend Browserino within your rails app, this is certainly possible. Create a file config/initializers/browserino.rb and add the following:
Browserino.config.define do
# your magic here
end
Please skip ahead to the Config part of the documentation, that section contains information on how to make use of Browserino's builtin DSL
Usage
Client
the parse method will always return a Browserino::Client object. This object is special in that it simply resonds to everything. If a property does not exist or isn't defined on the current instance of client then it will simply return nil. Parsing an empty user agent will result in the following output:
client = Browserino.parse ''
client.is_a? Browserino::Client # => true
Prior to version 4.4.1, Browserino.parse nil or Browserino.parse false were invalid. As of 4.4.1 an empty user agent ('') is assumed when these values are used.
Formatting
This section explains the output / return values given by calling a method on an instantiated Browserino::client object.
Related Skills
node-connect
348.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
