js-is-webview

1.0.2 • Public • Published

js-is-webview

use javascrupt to know it is webview ? support node and the browser(webpack)

install

npm install js-is-webview --save

usage in node

pass User-Agent sniffing,know the HTTP/HTTPS request is performed by a UIWebview/Webview or not.

const isWebview = require("js-is-webview");
const is_webview = new isWebview();
 
const server = (req, res, next) => {
    - let userAgent = {
        - userAgent:req.headers['User-Agent']
    }
    // if true
    if(isWebview.check(userAgent))){
        //...
        next();
    }
};

usage in the browser

pass the browser features and properties,know it is webview or

const isWebview = require("js-is-webview");
const is_webview = new isWebview();
 
let userAgent = {
    userAgent:navigator.userAgent
}
 
if(isWebview.check(userAgent))){
    //...
}

API

iswebview.check({userAgent})

  • userAgent (Object.key): Browser User-Agent header string
if(isWebview.check({userAgent}))){
    //...
}

iswebview.check({userAgent, configObject})

  • userAgent (Object.key): Browser User-Agent header string
  • configObject (Object)
    • appName (String): the app name explicitly set in your WebView properties/settings.

Package Sidebar

Install

npm i js-is-webview

Weekly Downloads

31

Version

1.0.2

License

ISC

Unpacked Size

11.1 kB

Total Files

14

Last publish

Collaborators

  • qiangqiang