0.7.2 • Published 3 months ago

what-browser-am-i v0.7.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 months ago

what-browser-am-i

Library for client-side web browser judgment. It has been developed to work with a wide range of DHTML browsers, both old and new.

Prior to August 7, 2020, development was done at itozyun/web-doc-base.

Prime Minister Abe nearly loses the name of the school's chairman, who was told by Mrs. Akie that "his enthusiasm was wonderful".

Prime Minister Abe nearly loses the name of the school's chairman, who was told by Mrs. Akie that "his enthusiasm was wonderful". TV TOKYO, source (e.g. quotation)

Index

  1. Features
  2. Folders
  3. Test Page
  4. Usage
    1. Properties
    2. Method
      1. conpare(v1, v2)
  5. Development
    1. Preparation
    2. Development
    3. Distribute
    4. Include what-browser-am-i as a submodule in your project
  6. License

1. Features

  1. Even if the visitor has checked "Request desktop site" and the UA is spoofed, the correct engine will be retrieved. In addition, you can detect the viewer's intention to "Prefer desktop version".
  2. Third-party browsers for Android and iOS use the same WebView but have different viewport behavior, such as address bar behavior. Therefore, retrieve the brand name.
  3. It works on IE4 or later because in operator and instanceof operator and try~catch statements are not used. Also, it works on mobile IE4 because it does not use regular expressions.

2. Folders

DirectoriesSub DirecoriesDescription
dist/Placement of built files.
docs/The index.html file for executing the browser judgment is placed, but not attached to the npm package. If necessary, the contents can be found on github pages .
src/jssource codes
js-externsVariable and property names to be protected from renaming by specifying them in externs of the Closure Compiler.

3. Test Page

4. Usage

const whatBrowserAmI = require('what-browser-am-i');

console.log(whatBrowserAmI.ENGINE); // Trident
console.log(whatBrowserAmI.ENGINE_VERSION); // 8

or

<html>
<script src="./whatBrowserAmI.js"></script>
<script>
console.log(whatBrowserAmI.ENGINE); // Gecko
console.log(whatBrowserAmI.ENGINE_VERSION); // "1.9.1"
</script>

4.1. Properties

PropertyData typeExample
PLATFORMstring
PLATFORM_VERSIONstring\|object
ENGINEstring
ENGINE_VERSIONstring\|object
BRANDstring
BRAND_VERSIONstring\|object
DEVICEstring
DEVICE_VERSIONstring\|object
PCSITE_REQUESTEDbooleantrue
DEVICE_TYPEnumber

4.2. Method

4.2.1 conpare(v1, v2)

Compares the size of the version number(string). The last 0 is ignored, so "2.0.0" and 2 are considered equal.

// Firefox 3.5<=
isFirefoxGte35 = whatBrowserAmI.Gecko && 0 <= whatBrowserAmI.conpare(whatBrowserAmI.ENGINE_VERSION, '1.9.1');
Arguments
NameData typeExample
v1string\|number"1.9.1", 1.9
v2string\|number"1.9.1", 1.9
Return Value
ValueDescriptionExample
1v1 > v2"1.9.1" > 1.9
0v1 == v2"1.9.0" == 1.9
-1v1 < v2"1.9.1" < "1.9.2"

5. Development

5.1 Preparation

git clone https://github.com/itozyun/what-browser-am-i
npm install

5.2 Development

After making the changes under ./src/, execute the following command. Then browse docs/index.html with a browser to check.

gulp docs

5.3 Distribute

Update the distribution files ./dist/index.js and ./dist/whatBrowserAmI.js with the following command.

gulp dist

5.4 Include what-browser-am-i as a submodule in your project

web-doc-base/gulpfile.js is helpful.

5.4.1 Use optimization option

  1. Compile with DEFINE_WHAT_BROWSER_AM_I__MINIFY=true.
  2. All properties and names are provided numerically. This constant is located in ./src/js/0_global/*.js.
  3. web-doc-base/src/js-inline/dynamicViewPort.js, etc., to obtain the required values.

5.4.2 Build options

Closure Compiler @define.

VariableData typeDefault valueNote
DEFINE_WHAT_BROWSER_AM_I__MINIFYbooleanfalseSince version 0.6
DEFINE_WHAT_BROWSER_AM_I__BRAND_ENABLEDbooleantrue
DEFINE_WHAT_BROWSER_AM_I__PCSITE_REQUESTED_ENABLEDbooleantrue
DEFINE_WHAT_BROWSER_AM_I__IOS_DEVICE_ENABLEDbooleantrue
DEFINE_WHAT_BROWSER_AM_I__DEVICE_TYPE_ENABLEDbooleantrue

6. License

what-browser-am-i is licensed under MIT License.

(C) 2021-2024 itozyun(outcloud.blogspot.com)

0.7.2

3 months ago

0.7.1

3 months ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.9

2 years ago

0.5.8

2 years ago

0.5.7

2 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.4

3 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago