A simple device and browser sniffer... mostly using navigator.userAgent (yikes)
npm install whodisJust a simple little sniffer (that mostly uses navigator.userAgent) so you can rock conditional checks.
npm run buildUses microbundle to build out in cjs, es, umd.
npm run devWatches for changes in src.
npm i whodisimport WhoDis from 'whodis'import WhoDis from ./WhoDisOr, don't import and just use src/WhoDis.es5.js, which is just an ES5 IIFE.
import WhoDis from 'who-dis'// Add class to html
const html = document.querySelector('html');
if ( WhoDis.anyMS() ) {
html.classList.add('is-ms');
}
if ( WhoDis.IE() ) {
html.classList.add('is-ie');
}
if ( WhoDis.Safari() ) {
html.classList.add('is-safari');
}
// bail if mobile
if (WhoDis.anyMobile) return;
`Log info on current
userAgent`
console.log(WhoDis.info)
`Current Checks
$3
- Android : WhoDis.Android()
- BlackBerry : WhoDis.BlackBerry()
- iOS : WhoDis.iOS()
- Opera Mini : WhoDis.OperaMini()
- IE Mobile : WhoDis.IEMobile()
- Any Mobile (checks all the above) : WhoDis.anyMobile()
- Touch Screen : WhoDis.Touch()$3
- Edge : WhoDis.Edge()
- IE : WhoDis.IE()
- IE10 : WhoDis.IE10()
- anyMS (IEs and Edge) : WhoDis.anyMS()$3
- Chrome : WhoDis.Chrome()
- Safari : WhoDis.Safari()
- Firefox : WhoDis.Firefox()
- Opera : WhoDis.Opera()`