-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
106 lines (97 loc) · 3.3 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const {getSysInfo} = require('./sys-info.js');
/**
* Chrome user agent
*
* @param {number | string} version Browser version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function chrome(version, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + ') AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' + version + ' Safari/537.36';
}
/**
* Chrome user agent with advanced options
*
* @param {number | string} version Browser version
* @param {number | string} webkitVersion Webkit version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function chromeAdvanced(version, webkitVersion, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + ') AppleWebKit/' + webkitVersion + ' (KHTML, like Gecko) Chrome/' + version + ' Safari/' + webkitVersion;
}
/**
* Safari user agent
*
* @param {number | string} version Browser version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function firefox(version, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + '; rv:' + version + ') Gecko/20100101 Firefox/' + version;
}
/**
* Firefox user agent with advanced options
*
* @param {number | string} version Browser version
* @param {number | string} geckoVersion Gecko version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function firefoxAdvanced(version, geckoVersion, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + '; rv:' + version + ') Gecko/' + geckoVersion + ' Firefox/' + version;
}
/**
* Opera user agent
*
* @param {number | string} version Browser version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function opera(version, sysInfo) {
return 'Opera/9.80 (' + getSysInfo(sysInfo) + ') Presto/2.12.388 Version/' + version;
}
/**
* Opera user agent with advanced options
*
* @param {number | string} version Browser version
* @param {number | string} prestoVersion Presto version
* @param {number | string} operaVersion Opera version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function operaAdvanced(version, prestoVersion, operaVersion, sysInfo) {
return 'Opera/' + operaVersion + ' (' + getSysInfo(sysInfo) + ') Presto/' + prestoVersion + ' Version/' + version;
}
/**
* Safari user agent
*
* @param {number | string} version Browser version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function safari(version, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + ') AppleWebKit/601.4.8 (KHTML, like Gecko) Version/' + version + ' Safari/601.4.8';
}
/**
* Safari user agent with advanced options
*
* @param {number | string} version Browser version
* @param {number | string} webkitBuildVersion Webkit build version
* @param {number | string} safariBuildVersion Safari build version
* @param {string} [sysInfo] System information
* @returns {string} User agent
*/
function safariAdvanced(version, webkitBuildVersion, safariBuildVersion, sysInfo) {
return 'Mozilla/5.0 (' + getSysInfo(sysInfo) + ') AppleWebKit/' + webkitBuildVersion + ' (KHTML, like Gecko) Version/' + version + ' Safari/' + safariBuildVersion;
}
module.exports = {
chrome,
chromeAdvanced,
firefox,
firefoxAdvanced,
opera,
operaAdvanced,
safari,
safariAdvanced
};