Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created May 15, 2020 00:37
Show Gist options
  • Select an option

  • Save bitfishxyz/f9e2a81d59de524b049d79c0e92c8fba to your computer and use it in GitHub Desktop.

Select an option

Save bitfishxyz/f9e2a81d59de524b049d79c0e92c8fba to your computer and use it in GitHub Desktop.

Revisions

  1. @bitfish2020 bitfish2020 created this gist May 15, 2020.
    12 changes: 12 additions & 0 deletions v.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    const inBrowser = typeof window !== 'undefined'
    const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
    const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
    const UA = inBrowser && window.navigator.userAgent.toLowerCase()
    const isIE = UA && /msie|trident/.test(UA)
    const isIE9 = UA && UA.indexOf('msie 9.0') > 0
    const isEdge = UA && UA.indexOf('edge/') > 0
    const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
    const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
    const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
    const isPhantomJS = UA && /phantomjs/.test(UA)
    const isFF = UA && UA.match(/firefox\/(\d+)/)