{"id":13826530,"url":"https://github.com/wilddeer/sniffer","last_synced_at":"2025-04-05T12:07:16.976Z","repository":{"id":10664941,"uuid":"12898655","full_name":"wilddeer/Sniffer","owner":"wilddeer","description":"browser/engine/os/device detection tool","archived":false,"fork":false,"pushed_at":"2022-12-07T14:05:55.000Z","size":523,"stargazers_count":178,"open_issues_count":7,"forks_count":18,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-04-14T05:30:41.953Z","etag":null,"topics":["javascript","sniffer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wilddeer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-17T15:10:09.000Z","updated_at":"2024-01-21T02:44:05.000Z","dependencies_parsed_at":"2023-01-13T16:24:38.665Z","dependency_job_id":null,"html_url":"https://github.com/wilddeer/Sniffer","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddeer%2FSniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddeer%2FSniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddeer%2FSniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilddeer%2FSniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilddeer","download_url":"https://codeload.github.com/wilddeer/Sniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332609,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","sniffer"],"created_at":"2024-08-04T09:01:39.804Z","updated_at":"2025-04-05T12:07:16.954Z","avatar_url":"https://github.com/wilddeer.png","language":"JavaScript","readme":"# Sniffer\n\nSniffer is a browser/engine/os/device detection tool. Works both in a browser and with Node.\n\n[Live demo](http://wilddeer.github.io/Sniffer/test/demo.htm) (tests your browser UA string)\n\n[Test suite](http://wilddeer.github.io/Sniffer/test/test.htm)\n\n## You have three options:\n\n### 1. Default Sniffer build\n\nGet *sniffer.js* from [dist/](https://github.com/wilddeer/Sniffer/tree/master/dist). Drop the script tag in the `\u003chead\u003e`:\n\n```js\n\u003cscript src=\"path/to/sniffer.js\"\u003e\u003c/script\u003e\n```\n\nIt will run automatically, collect the information on current device/os/browser and put the results in `window.Sniff` object (or expose it via `module.exports`, if available). See [“Detection results”](#detection-results) for details. Now you can do horrible things:\n\n```js\nif (Sniff.os.name=='android' \u0026\u0026\n\tSniff.os.majorVersion \u0026\u0026\n\tSniff.os.majorVersion \u003c 3 \u0026\u0026\n\t!Sniff.browser.name \u0026\u0026\n\tSniff.browser.engine=='webkit') {\n\t\t//looks like default Android 2.x browser!\n\t\tmyMagicOverflowScrollPolyfill();\n}\n```\n\nIt will also add browser name shortcode, browser engine shortcode, OS name shortcode and device features’ shortcodes to `\u003chtml\u003e` tag’s className, so you can alter the styles accordingly (pretty much the Modernizr way):\n\n```css\n/* contrast colors for monochrome devices */\nhtml.bw body {\n\tcolor: black;\n\tbackground: white;\n}\n\n/* make sure code snippets are readable in Opera Mini */\nhtml.operamini pre code {\n\twhite-space: pre-wrap;\n}\n```\n\n### 2. Sniffer module\n\nGet *sniffer.module.js* from [dist/](https://github.com/wilddeer/Sniffer/tree/master/dist). It exposes Sniffer function into global scope or via `module.exports`, if available. Compatible with Node. Just feed it a user agent string:\n\n```js\nSniffer(userAgent);\n```\n\nIt will return detection result, see [“Detection results”](#detection-results) for details.\n\nAlso available via npm: `npm install snifferjs`.\n\n### 3. Pure Sniffer function\n\nGet *sniffer.pure.js* from [dist/](https://github.com/wilddeer/Sniffer/tree/master/dist). It contains pure Sniffer function (no wrap, no autolaunch, no css classes, no exports), you decide how to use it.\n\n## Detection results\n\nSniffer returns an object which looks like this:\n\n```js\n{\n\tbrowser: {\n\t\tfullName: String, // full human readable name\n\t\tname: String, // shortcode\n\t\tversion: String, // semantic version, up to three parts (major.minor.patch)\n\t\tmajorVersion: Number,\n\t\tminorVersion: Number,\n\t\tpatchVersion: Number,\n\t\tengine: String // shortcode\n\t},\n\tos: {\n\t\tfullName: String, // full human readable name\n\t\tname: String, // shortcode\n\t\tversion: String, // semantic version, up to three parts (major.minor.patch)\n\t\tversionName: String, // human readable version name, e.g. 'Vista', 'Mavericks', etc.\n\t\tversionAltNames: Array, // possible alternatives, e.g. Windows NT 5.2 can be 'XP' or 'Server 2003'\n\t\tmajorVersion: Number,\n\t\tminorVersion: Number,\n\t\tpatchVersion: Number\n\t},\n\tfeatures: {\n\t\tbw: Boolean, /* black and white (e-book readers) */\n\t\tmobile: Boolean, /* includes phones, tablets, e-book readers, portable game consoles, etc. */\n\t\ttv: Boolean, /* smart tv */\n\t\tproxy: Boolean /* serverside js \u0026 rendering, like in Opera Mini */\n\t}\n}\n```\n\n## Detects\n\nClass names/shortcodes in square brackets.\n\n**Browsers:**\n\n- **Chrome** *[chrome]*\n- **Firefox** *[firefox]*\n- **IE** *[ie]*\n- **Edge** *[edge]*\n- **Safari** *[safari]*\n- **Opera** *[opera]*\n- **Opera Mini** *[operamini]*\n- **Opera Coast** *[coast]*\n- **Nokia Browser** *[nokiabrowser]* (!= Nokia Xpress) — Symbian Belle phones\n- **Ovi Browser** a.k.a **Nokia Xpress** *[ovi]* — Nokia Asha, Series40 \u0026amp; Series60 phones, etc.\n- **Sailfish Browser** *[sailfishbrowser]*\n\n**Engines:**\n\n- **WebKit** *[webkit]*\n- **Gecko** *[gecko]*\n- **Trident** *[trident]*\n- **Presto** *[presto]*\n- **EdgeHTML** *[edgehtml]*\n\n**OS/Devices:**\n\n- **Windows** *[win]*\n- **Mac OS X** *[osx]*\n- **Ubuntu** *[ubuntu]*\n- **Fedora** *[fedora]*\n- **Windows Phone** *[winphone]*\n- **Android** *[android]*\n- **iOS** *[ios]*\n- **BlackBerry** *[blackberry]*\n- **Sailfish OS** *[sailfish]*\n- **Symbian** *[symbian]*\n- **Kindle** *[kindle]* (Kindle Fire should be detected as Android)\n- **PlayStation** *[playstation]*\n- **PlayStation Vita** *[psvita]*\n- **Nintendo DSi** *[dsi]*\n- **Nintendo 3DS** *[3ds]*\n- **New Nintendo 3DS** *[n3ds]*\n- **Viera** *[viera]* (Panasonic Viera smart tv)\n\n**Features:**\n\n- **Black and white** *[bw]*\n- **Mobile** *[mobile]*\n- **TV** *[tv]*\n- **Proxy broswer** (serverside rendering) *[proxy]*\n\n## License\n\n[MIT license](http://opensource.org/licenses/MIT).\n\nHave fun, lads.\n","funding_links":[],"categories":["\u003ca id=\"7bf0f5839fb2827fdc1b93ae6ac7f53d\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"32739127f0c38d61b14448c66a797098\"\u003e\u003c/a\u003e嗅探\u0026\u0026Sniff"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddeer%2Fsniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilddeer%2Fsniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilddeer%2Fsniffer/lists"}