-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy path_window.js
378 lines (371 loc) · 9.24 KB
/
_window.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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
class BlueTooth {
constructor() {
this.onadvertisementreceived = null;
}
}
class ClipBoard {
constructor() {}
}
class NetworkInformation {
constructor() {
this.downlink = 1.45;
this.downlinkMax = (1e311);
this.effectiveType = '4g';
this.onchange = null;
this.ontypechange = null;
this.rtt = 0;
this.saveData = false;
this.type = 'wifi'
}
}
class ContactsManager {
constructor() {}
}
class CredentialsContainer {
constructor() {}
}
class DevicePosture {
constructor() {
this.onchange = null;
this.type = 'continuous';
}
}
class Geolocation {
constructor() {}
}
class WSGLLanguageFeatures {
constructor() {
this.size = 0;
}
}
class GPU {
constructor() {
this.wgslLanguageFeatures = new WSGLLanguageFeatures();
}
}
class Ink {
constructor() {}
}
class Keyboard {
constructor() {}
}
class LocksManager {
constructor() {}
}
class NavigatorManagedData {
constructor() {
this.onmanagedconfigurationchange = null;
}
}
class MediaCapabilities {
constructor() {}
}
class MediaDevices {
constructor() {}
}
class MediaSession {
constructor() {
this.metadata = null;
this.playbackState = 'none';
}
}
class MimeTypeArray {
constructor() {
this.length = 0;
}
}
class ML {
constructor() {}
}
class Permissions {
constructor() {}
}
class PluginArray {
constructor() {
this.length = 0;
}
}
class Presentation {
constructor() {
this.defaultRequest = null;
this.receiver = null;
}
}
class Scheduling {
constructor() {}
}
class ServiceWorkerContainer {
constructor() {
this.controller = null;
this.oncontrollerchange = null;
this.onmessage = null;
this.onmessageerror = null;
}
}
class StorageManager {
constructor() {
this.onquotachange = null;
}
}
class StorageBucketManager {
constructor() {}
}
class USB {
constructor() {
this.onconnect = null;
this.ondisconnect = null;
}
}
class UserActivation {
constructor() {
this.hasBeenActive = false;
this.isActive = false;
}
}
class NavigatorUAData {
constructor() {
this.brands = [
{brand: 'Not-A.Brand', version: '99'},
{brand: 'Chromium', version: '124'}
];
this.mobile = true;
this.platform = 'Android';
}
}
class DOMRect {
constructor() {
this.bottom = 0;
this.height = 0;
this.left = 0;
this.right = 0;
this.top = 0;
this.width = 0;
this.x = 0;
this.y = 0;
}
}
class VirtualKeyboard {
constructor() {
this.boundingRect = new DOMRect();
this.ongeometrychange = null;
this.overlaysContent = false;
}
}
class XRSystem {
constructor() {
this.ondevicechange = null;
}
}
class WakeLock {
constructor() {}
}
class DeprecatedStorageQuota {
constructor() {}
}
class NavigationHistoryEntry {
constructor() {
this.id = '03df9dc8-4c2b-4148-917c-e3508f3a739e';
this.index = 0;
this.key = 'db62fa24-b3ed-47a4-bd63-d97a4f7f2c72';
this.ondispose = null;
this.sameDocument = true;
this.url = '';
}
}
class Navigation {
constructor() {
this.canGoBack = false;
this.canGoForward = false;
this.currentEntry = new NavigationHistoryEntry();
this.onnavigate = null;
this.oncurrententrychange = null;
this.onnavigateerror = null;
this.onnavigatesuccess = null;
this.transition = null;
}
}
window._navigatorIDTest = crypto.randomUUID()
window.mockPerformance = function(entryType, initiator, name) {
return {
initiatorType: initiator,
name: name,
entryType: entryType,
encodedBodySize: Math.floor(Math.random() * (9000 - 300 + 1)) + 100,
requestStart: Math.random() * (200 - 100) + 50,
responseStart: Math.random() * (300 - 400) + 70,
responseEnd: Math.random() * (450 - 700) + 100,
duration: Math.random() * (200 - 300) + 20,
startTime: Math.random() * (200 - 300) + 20,
navigationId: window._navigatorIDTest
}
}
window.matchMedia = function (query) {
const width = window.innerWidth || 1024;
const height = window.innerHeight || 768;
const matches = evaluateMediaQuery(query, { width, height });
let listener = null;
return {
matches,
media: query,
addEventListener: (event, callback) => {
if (event === "change") listener = callback;
},
removeEventListener: () => {
listener = null;
},
dispatchChange: () => {
if (listener) {
const newMatches = evaluateMediaQuery(query, {
width: window.innerWidth,
height: window.innerHeight,
});
listener({ matches: newMatches, media: query });
}
},
};
function evaluateMediaQuery(query, dimensions) {
const { width } = dimensions;
if (query.includes("max-width")) {
const maxWidth = parseInt(query.match(/max-width:\s*(\d+)px/)[1], 10);
return width <= maxWidth;
}
if (query.includes("min-width")) {
const minWidth = parseInt(query.match(/min-width:\s*(\d+)px/)[1], 10);
return width >= minWidth;
}
return false;
}
}
window.HTMLCanvasElement.prototype.getContext = function () {
return {
fillRect: function() {},
clearRect: function(){},
getImageData: function(x, y, w, h) {
return {
data: new Array(w*h*4)
};
},
putImageData: function() {},
createImageData: function(){ return []},
setTransform: function(){},
drawImage: function(){},
save: function(){},
fillText: function(){},
restore: function(){},
beginPath: function(){},
moveTo: function(){},
lineTo: function(){},
closePath: function(){},
stroke: function(){},
translate: function(){},
scale: function(){},
rotate: function(){},
arc: function(){},
fill: function(){},
measureText: function(){
return { width: 0 };
},
transform: function(){},
rect: function(){},
clip: function(){},
};
}
window.HTMLCanvasElement.prototype.toDataURL = function () {
return "";
}
window.chrome = {
'app': {},
'csi': function(){},
'loadTimes': function(){}
}
window.navigation = new Navigation()
window.simulation_getClientRects = function () {
const simulatedRects = [
{
x: 10,
y: 20,
width: 100,
height: 50,
top: 20,
left: 10,
bottom: 70,
right: 110,
},
{
x: 30,
y: 50,
width: 150,
height: 80,
top: 50,
left: 30,
bottom: 130,
right: 180,
},
];
return {
length: simulatedRects.length,
item(index) {
return simulatedRects[index] || null;
},
...simulatedRects,
};
};
const clientNavigator = userAgent => {
// navigator client simulation
var language = 'es-CO';
var languages_list = ['es-CO', 'es-US', 'es-419', 'es'];
window.clientInformation = {
appCodeName: userAgent.split('/')[0],
appName: 'Netscape',
appVersion: userAgent.split('Mozilla/')[1],
bluetooth: new BlueTooth(),
clipboard: new ClipBoard(),
connection: new NetworkInformation(),
contacts: new ContactsManager(),
cookieEnabled: true,
credentials: new CredentialsContainer(),
deviceMemory: (2 << Math.floor(Math.random() * 6)),
devicePosture: new DevicePosture(),
doNotTrack: null,
geolocation: new Geolocation(),
gpu: new GPU(),
hardwareConcurrency: 8,
ink: new Ink(),
keyboard: new Keyboard(),
language: language,
languages: languages_list,
locks: new LocksManager(),
managed: new NavigatorManagedData(),
maxTouchPoints: 5,
mediaCapabilities: new MediaCapabilities(),
mediaDevices: new MediaDevices(),
mediaSession: new MediaSession(),
mimeTypes: new MimeTypeArray(),
ml: new ML(),
onLine: true,
pdfViewerEnabled: false,
permissions: new Permissions(),
platform: 'Linux x86_64',
plugins: new PluginArray(),
presentation: new Presentation(),
product: 'Gecko',
productSub: '20030107',
scheduling: new Scheduling(),
serviceWorker: new ServiceWorkerContainer(),
storage: new StorageManager(),
storageBuckets: new StorageBucketManager(),
usb: new USB(),
userActivation: new UserActivation(),
userAgent: userAgent,
userAgentData: new NavigatorUAData(),
vendor: 'Google Inc.',
vendorSub: '',
virtualKeyboard: new VirtualKeyboard(),
wakeLock: new WakeLock(),
webdriver: false,
webkitPersistentStorage: new DeprecatedStorageQuota(),
webkitTemporaryStorage: new DeprecatedStorageQuota(),
xr: new XRSystem()
}
return window
}