Repository navigation
Expand file tree
/
Copy pathCorrections.js
More file actions
148 lines (137 loc) · 4.46 KB
/
Copy pathCorrections.js
File metadata and controls
148 lines (137 loc) · 4.46 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* eslint-disable require-jsdoc */
const Constants = require('../constants');
class Corrections {
static applyCorrections() {
if (this.data.browser.name && this.data.browser.using) {
Corrections.hideBrowserBasedOnUsing.call(this);
}
if (this.data.browser.name && this.data.os.name) {
Corrections.hideBrowserBasedOnOperatingSystem.call(this);
}
if (this.data.browser.name && this.data.device.type === Constants.deviceType.TELEVISION) {
Corrections.hideBrowserOnDeviceTypeTelevision.call(this);
}
if (this.data.browser.name && this.data.device.type === Constants.deviceType.GAMING) {
Corrections.hideBrowserOnDeviceTypeGaming.call(this);
}
if (this.data.device.type === Constants.deviceType.TELEVISION) {
Corrections.hideOsOnDeviceTypeTelevision.call(this);
}
if (this.data.browser.name && this.data.engine.name) {
Corrections.fixMidoriEngineName.call(this);
}
if (this.data.browser.name && this.data.engine.name) {
Corrections.fixNineSkyEngineName.call(this);
}
if (this.data.browser.name && this.data.browser.family) {
Corrections.hideFamilyIfEqualToBrowser.call(this);
}
return this;
}
static hideFamilyIfEqualToBrowser() {
if (this.data.browser.name === this.data.browser.family.name) {
this.data.browser.family = null;
}
}
static fixMidoriEngineName() {
if (this.data.browser.name === 'Midori' && this.data.engine.name !== 'Webkit') {
this.data.engine.name = 'Webkit';
this.data.engine.version = null;
}
}
static fixNineSkyEngineName() {
if (this.data.browser.name === 'NineSky' && this.data.engine.name !== 'Webkit') {
this.data.engine.name = 'Webkit';
this.data.engine.version = null;
}
}
static hideBrowserBasedOnUsing() {
if (this.data.browser.name === 'Chrome') {
if (this.data.browser.isUsing('Electron') || this.data.browser.isUsing('Qt')) {
this.data.browser.name = null;
this.data.browser.version = null;
}
}
}
static hideBrowserBasedOnOperatingSystem() {
if (this.data.os.name === 'Series60' && this.data.browser.name === 'Internet Explorer') {
this.data.browser.reset();
this.data.engine.reset();
}
if (this.data.os.name === 'Series80' && this.data.browser.name === 'Internet Explorer') {
this.data.browser.reset();
this.data.engine.reset();
}
if (this.data.os.name === 'Lindows' && this.data.browser.name === 'Internet Explorer') {
this.data.browser.reset();
this.data.engine.reset();
}
if (this.data.os.name === 'Tizen' && this.data.browser.name === 'Chrome') {
this.data.browser.reset({
family: this.data.browser.family ? this.data.browser.family : null,
});
}
if (this.data.os.name === 'Ubuntu Touch' && this.data.browser.name === 'Chromium') {
this.data.browser.reset({
family: this.data.browser.family ? this.data.browser.family : null,
});
}
}
static hideBrowserOnDeviceTypeGaming() {
if (
this.data.device.model &&
this.data.device.model === 'Playstation 2' &&
this.data.browser.name === 'Internet Explorer'
) {
this.data.browser.reset();
}
}
static hideBrowserOnDeviceTypeTelevision() {
let valid;
switch (this.data.browser.name) {
case 'Firefox':
if (!this.data.isOs('Firefox OS')) {
this.data.browser.name = null;
this.data.browser.version = null;
}
break;
case 'Internet Explorer':
valid = this.data.device.model && ['WebTV'].includes(this.data.device.model);
if (!valid) {
this.data.browser.name = null;
this.data.browser.version = null;
}
break;
case 'Chrome':
case 'Chromium':
valid = this.data.os.name && ['Google TV', 'Android'].includes(this.data.os.name);
if (this.data.device.model && ['Chromecast'].includes(this.data.device.model)) {
valid = true;
}
if (!valid) {
this.data.browser.name = null;
this.data.browser.version = null;
}
break;
}
}
static hideOsOnDeviceTypeTelevision() {
if (
this.data.os.name &&
![
'Aliyun OS',
'Tizen',
'Android',
'Android TV',
'FireOS',
'Google TV',
'Firefox OS',
'OpenTV',
'webOS',
].includes(this.data.os.name)
) {
this.data.os.reset();
}
}
}
module.exports = Corrections;