@crawlee/browser-pool 3.13.6-beta.1 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstract-classes/browser-controller.d.ts +4 -4
- package/abstract-classes/browser-controller.d.ts.map +1 -1
- package/abstract-classes/browser-controller.js +43 -117
- package/abstract-classes/browser-controller.js.map +1 -1
- package/abstract-classes/browser-plugin.d.ts +5 -16
- package/abstract-classes/browser-plugin.d.ts.map +1 -1
- package/abstract-classes/browser-plugin.js +19 -71
- package/abstract-classes/browser-plugin.js.map +1 -1
- package/anonymize-proxy.js +4 -8
- package/anonymize-proxy.js.map +1 -1
- package/browser-pool.d.ts +6 -6
- package/browser-pool.d.ts.map +1 -1
- package/browser-pool.js +77 -209
- package/browser-pool.js.map +1 -1
- package/container-proxy-server.js +3 -6
- package/container-proxy-server.js.map +1 -1
- package/events.js +4 -7
- package/events.js.map +1 -1
- package/fingerprinting/hooks.d.ts +3 -3
- package/fingerprinting/hooks.d.ts.map +1 -1
- package/fingerprinting/hooks.js +13 -18
- package/fingerprinting/hooks.js.map +1 -1
- package/fingerprinting/types.js +6 -9
- package/fingerprinting/types.js.map +1 -1
- package/fingerprinting/utils.d.ts +2 -2
- package/fingerprinting/utils.d.ts.map +1 -1
- package/fingerprinting/utils.js +9 -13
- package/fingerprinting/utils.js.map +1 -1
- package/index.d.ts +13 -13
- package/index.d.ts.map +1 -1
- package/index.js +11 -26
- package/index.js.map +1 -1
- package/launch-context.d.ts +2 -9
- package/launch-context.d.ts.map +1 -1
- package/launch-context.js +12 -73
- package/launch-context.js.map +1 -1
- package/logger.js +2 -6
- package/logger.js.map +1 -1
- package/package.json +19 -25
- package/playwright/playwright-browser.js +6 -30
- package/playwright/playwright-browser.js.map +1 -1
- package/playwright/playwright-controller.d.ts +2 -2
- package/playwright/playwright-controller.d.ts.map +1 -1
- package/playwright/playwright-controller.js +9 -75
- package/playwright/playwright-controller.js.map +1 -1
- package/playwright/playwright-plugin.d.ts +6 -6
- package/playwright/playwright-plugin.d.ts.map +1 -1
- package/playwright/playwright-plugin.js +19 -106
- package/playwright/playwright-plugin.js.map +1 -1
- package/proxy-server.js +3 -6
- package/proxy-server.js.map +1 -1
- package/puppeteer/puppeteer-controller.d.ts +1 -1
- package/puppeteer/puppeteer-controller.d.ts.map +1 -1
- package/puppeteer/puppeteer-controller.js +13 -17
- package/puppeteer/puppeteer-controller.js.map +1 -1
- package/puppeteer/puppeteer-plugin.d.ts +5 -5
- package/puppeteer/puppeteer-plugin.d.ts.map +1 -1
- package/puppeteer/puppeteer-plugin.js +16 -23
- package/puppeteer/puppeteer-plugin.js.map +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils.d.ts +3 -3
- package/utils.d.ts.map +1 -1
- package/utils.js +1 -4
- package/utils.js.map +1 -1
- package/index.mjs +0 -19
- package/playwright/load-firefox-addon.d.ts +0 -2
- package/playwright/load-firefox-addon.d.ts.map +0 -1
- package/playwright/load-firefox-addon.js +0 -86
- package/playwright/load-firefox-addon.js.map +0 -1
- package/tab-as-a-container/background.js +0 -433
- package/tab-as-a-container/content.js +0 -611
- package/tab-as-a-container/manifest.json +0 -21
|
@@ -1,611 +0,0 @@
|
|
|
1
|
-
// When in doubt, refer to https://github.com/nodejs/node/blob/main/doc/contributing/primordials.md
|
|
2
|
-
|
|
3
|
-
/* eslint-disable no-undef */
|
|
4
|
-
/* eslint-disable no-cond-assign */
|
|
5
|
-
/* eslint-disable prefer-rest-params */
|
|
6
|
-
/* eslint-disable no-shadow */
|
|
7
|
-
|
|
8
|
-
// TODO: https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store_API
|
|
9
|
-
// TODO: custom error messages for Firefox (for now it uses Chrome's)
|
|
10
|
-
|
|
11
|
-
// The only way to detect this "container" is to benchmark document.cookie or compare localStorage performance with sessionStorage (it's the same).
|
|
12
|
-
|
|
13
|
-
const isFirefox = navigator.userAgent.includes('Firefox');
|
|
14
|
-
const tabPrefix = `.${tabId}.`;
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
String,
|
|
18
|
-
Array,
|
|
19
|
-
Set,
|
|
20
|
-
TypeError,
|
|
21
|
-
WeakMap,
|
|
22
|
-
Object,
|
|
23
|
-
Number,
|
|
24
|
-
Function,
|
|
25
|
-
Proxy,
|
|
26
|
-
IDBFactory,
|
|
27
|
-
IDBDatabase,
|
|
28
|
-
BroadcastChannel,
|
|
29
|
-
Storage,
|
|
30
|
-
// We don't have to implement StorageEvent because this implementation does not use localStorage at all.
|
|
31
|
-
} = globalThis;
|
|
32
|
-
|
|
33
|
-
const ObjectDefineProperty = Object.defineProperty;
|
|
34
|
-
const ObjectDefineProperties = Object.defineProperties;
|
|
35
|
-
const ObjectGetOwnPropertyDescriptors = Object.getOwnPropertyDescriptors;
|
|
36
|
-
const ObjectGetPrototypeOf = Object.getPrototypeOf;
|
|
37
|
-
const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
38
|
-
const ObjectCreate = Object.create;
|
|
39
|
-
const ObjectEntries = Object.entries;
|
|
40
|
-
const ReflectGet = Reflect.get;
|
|
41
|
-
const ReflectSet = Reflect.set;
|
|
42
|
-
const ObjectKeys = Object.keys;
|
|
43
|
-
const NumberIsFinite = Number.isFinite;
|
|
44
|
-
|
|
45
|
-
const clonePrototype = (from) => {
|
|
46
|
-
const target = ObjectCreate(null);
|
|
47
|
-
const prototype = ObjectGetOwnPropertyDescriptors(from.prototype);
|
|
48
|
-
|
|
49
|
-
const entries = ObjectEntries(prototype);
|
|
50
|
-
|
|
51
|
-
for (let i = 0; i < entries.length; i++) {
|
|
52
|
-
const entry = entries[i];
|
|
53
|
-
|
|
54
|
-
const { 0: name, 1: descriptor } = entry;
|
|
55
|
-
target[name] = ObjectCreate(null);
|
|
56
|
-
|
|
57
|
-
if ('get' in descriptor) {
|
|
58
|
-
target[name].get = descriptor.get;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if ('set' in descriptor) {
|
|
62
|
-
target[name].set = descriptor.set;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if ('value' in descriptor) {
|
|
66
|
-
target[name] = descriptor.value;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return target;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const StringSplitSafe = (string, separator) => {
|
|
74
|
-
const result = [];
|
|
75
|
-
const separatorLength = separator.length;
|
|
76
|
-
|
|
77
|
-
if (separatorLength === 0) {
|
|
78
|
-
throw new Error('Separator must not be empty');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
let startFrom = 0;
|
|
82
|
-
let index;
|
|
83
|
-
while ((index = StringPrototype.indexOf.call(string, separator, startFrom)) !== -1) {
|
|
84
|
-
ArrayPrototype.push.call(result, StringPrototype.slice.call(string, startFrom, index));
|
|
85
|
-
|
|
86
|
-
startFrom = index + separatorLength;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const lastChunk = StringPrototype.slice.call(string, startFrom);
|
|
90
|
-
|
|
91
|
-
ArrayPrototype.push.call(result, lastChunk);
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const fixStack = (error) => {
|
|
97
|
-
const lines = StringSplitSafe(error.stack, '\n');
|
|
98
|
-
|
|
99
|
-
if (isFirefox) {
|
|
100
|
-
ArrayPrototype.splice.call(lines, 0, 1);
|
|
101
|
-
} else {
|
|
102
|
-
ArrayPrototype.splice.call(lines, 1, 1);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
error.stack = ArrayPrototype.join.call(lines, '\n');
|
|
106
|
-
|
|
107
|
-
return error;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const SetPrototype = clonePrototype(Set);
|
|
111
|
-
const WeakMapPrototype = clonePrototype(WeakMap);
|
|
112
|
-
const ArrayPrototype = clonePrototype(Array);
|
|
113
|
-
const StringPrototype = clonePrototype(String);
|
|
114
|
-
const IDBFactoryPrototype = clonePrototype(IDBFactory);
|
|
115
|
-
const IDBDatabasePrototype = clonePrototype(IDBDatabase);
|
|
116
|
-
const StoragePrototype = clonePrototype(Storage);
|
|
117
|
-
|
|
118
|
-
const privates = new WeakMap();
|
|
119
|
-
|
|
120
|
-
let invocable = false;
|
|
121
|
-
|
|
122
|
-
const FakeStorage = class Storage {
|
|
123
|
-
constructor() {
|
|
124
|
-
if (invocable) {
|
|
125
|
-
throw fixStack(new TypeError('Illegal constructor'));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
WeakMapPrototype.set.call(privates, this, arguments[0]);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
get length() {
|
|
132
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
133
|
-
if (!priv) {
|
|
134
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const { storage, prefix } = priv;
|
|
138
|
-
const length = StoragePrototype.length.get.call(storage);
|
|
139
|
-
|
|
140
|
-
let fakeLength = 0;
|
|
141
|
-
for (let i = 0; i < length; i++) {
|
|
142
|
-
const storageKey = StoragePrototype.key.call(storage, i);
|
|
143
|
-
if (StringPrototype.startsWith.call(storageKey, prefix)) {
|
|
144
|
-
fakeLength++;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return fakeLength;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
clear() {
|
|
152
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
153
|
-
if (!priv) {
|
|
154
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const { storage, prefix } = priv;
|
|
158
|
-
const length = StoragePrototype.length.get.call(storage);
|
|
159
|
-
const keys = [];
|
|
160
|
-
|
|
161
|
-
for (let i = 0; i < length; i++) {
|
|
162
|
-
ArrayPrototype.push.call(keys, StoragePrototype.key.call(storage, i));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
for (let i = 0; i < length; i++) {
|
|
166
|
-
const storageKey = keys[i];
|
|
167
|
-
if (StringPrototype.startsWith.call(storageKey, prefix)) {
|
|
168
|
-
StoragePrototype.removeItem.call(storage, storageKey);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
key(index) {
|
|
174
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
175
|
-
if (!priv) {
|
|
176
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (arguments.length === 0) {
|
|
180
|
-
throw fixStack(
|
|
181
|
-
new TypeError(`Failed to execute 'key' on 'Storage': 1 argument required, but only 0 present.`),
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
index = NumberIsFinite(index) ? index : 0;
|
|
186
|
-
|
|
187
|
-
const { storage, prefix } = priv;
|
|
188
|
-
const length = StoragePrototype.length.get.call(storage);
|
|
189
|
-
|
|
190
|
-
let fakeLength = 0;
|
|
191
|
-
for (let i = 0; i < length; i++) {
|
|
192
|
-
const storageKey = StoragePrototype.key.call(storage, i);
|
|
193
|
-
|
|
194
|
-
if (StringPrototype.startsWith.call(storageKey, prefix)) {
|
|
195
|
-
if (fakeLength === index) {
|
|
196
|
-
return StringPrototype.slice.call(storageKey, prefix.length);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
fakeLength++;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return null;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
getItem(key) {
|
|
207
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
208
|
-
if (!priv) {
|
|
209
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (arguments.length === 0) {
|
|
213
|
-
throw fixStack(
|
|
214
|
-
new TypeError(`Failed to execute 'getItem' on 'Storage': 1 argument required, but only 0 present.`),
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return StoragePrototype.getItem.call(priv.storage, priv.prefix + key);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
removeItem(key) {
|
|
222
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
223
|
-
if (!priv) {
|
|
224
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (arguments.length === 0) {
|
|
228
|
-
throw fixStack(
|
|
229
|
-
new TypeError(`Failed to execute 'removeItem' on 'Storage': 1 argument required, but only 0 present.`),
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
StoragePrototype.removeItem.call(priv.storage, priv.prefix + key);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
setItem(key, value) {
|
|
237
|
-
const priv = WeakMapPrototype.get.call(privates, this);
|
|
238
|
-
if (!priv) {
|
|
239
|
-
throw fixStack(new TypeError('Illegal invocation'));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (arguments.length === 0 || arguments.length === 1) {
|
|
243
|
-
throw fixStack(
|
|
244
|
-
new TypeError(
|
|
245
|
-
`Failed to execute 'setItem' on 'Storage': 2 arguments required, but only ${arguments.length} present.`,
|
|
246
|
-
),
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
StoragePrototype.setItem.call(priv.storage, priv.prefix + key, value);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
const FakeStoragePrototype = clonePrototype(FakeStorage);
|
|
255
|
-
|
|
256
|
-
const createStorage = ({ storage, prefix }) => {
|
|
257
|
-
invocable = false;
|
|
258
|
-
const fake = new FakeStorage({ storage, prefix });
|
|
259
|
-
invocable = true;
|
|
260
|
-
|
|
261
|
-
const proxy = new Proxy(fake, {
|
|
262
|
-
__proto__: null,
|
|
263
|
-
// Default:
|
|
264
|
-
// apply: (target, thisArg, args) => {},
|
|
265
|
-
// construct(target, args) => {},
|
|
266
|
-
// setPrototypeOf: (target, proto) => {},
|
|
267
|
-
// getPrototypeOf: (target) => {},
|
|
268
|
-
defineProperty: (target, key, descriptor) => {
|
|
269
|
-
if ('set' in descriptor || 'get' in descriptor) {
|
|
270
|
-
throw fixStack(
|
|
271
|
-
new TypeError(`Failed to set a named property on 'Storage': Accessor properties are not allowed.`),
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
FakeStoragePrototype.setItem.call(target, key, descriptor.value);
|
|
276
|
-
},
|
|
277
|
-
deleteProperty: (target, key) => {
|
|
278
|
-
if (typeof key === 'symbol') {
|
|
279
|
-
delete target[key];
|
|
280
|
-
} else {
|
|
281
|
-
FakeStoragePrototype.removeItem.call(target, key);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return true;
|
|
285
|
-
},
|
|
286
|
-
get: (target, key) => {
|
|
287
|
-
if (typeof key === 'symbol') {
|
|
288
|
-
return target[key];
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (key in target) {
|
|
292
|
-
return ReflectGet(target, key);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return FakeStoragePrototype.getItem.call(target, key) ?? undefined;
|
|
296
|
-
},
|
|
297
|
-
set: (target, key, value) => {
|
|
298
|
-
if (typeof key === 'symbol') {
|
|
299
|
-
ObjectDefineProperty(target, key, {
|
|
300
|
-
__proto__: null,
|
|
301
|
-
value,
|
|
302
|
-
configurable: true,
|
|
303
|
-
writable: true,
|
|
304
|
-
enumerable: false,
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
return true;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (key in target) {
|
|
311
|
-
return ReflectSet(target, key, value);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return FakeStoragePrototype.setItem.call(target, key, value) ?? true;
|
|
315
|
-
},
|
|
316
|
-
has: (target, key) => {
|
|
317
|
-
if (key in target) {
|
|
318
|
-
return true;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return FakeStoragePrototype.getItem.call(target, key) !== null;
|
|
322
|
-
},
|
|
323
|
-
isExtensible: () => {
|
|
324
|
-
return true;
|
|
325
|
-
},
|
|
326
|
-
preventExtensions: () => {
|
|
327
|
-
throw fixStack(new TypeError(`Cannot prevent extensions`));
|
|
328
|
-
},
|
|
329
|
-
getOwnPropertyDescriptor: (target, key) => {
|
|
330
|
-
if (key in target) {
|
|
331
|
-
return ObjectGetOwnPropertyDescriptor(ObjectGetPrototypeOf(target), key);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const value = FakeStoragePrototype.getItem.call(target, key);
|
|
335
|
-
|
|
336
|
-
if (value !== null) {
|
|
337
|
-
return {
|
|
338
|
-
value,
|
|
339
|
-
writable: true,
|
|
340
|
-
enumerable: true,
|
|
341
|
-
configurable: true,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
},
|
|
345
|
-
ownKeys: (target) => {
|
|
346
|
-
const keys = [];
|
|
347
|
-
|
|
348
|
-
const { storage, prefix } = WeakMapPrototype.get.call(privates, target);
|
|
349
|
-
const length = StoragePrototype.length.get.call(storage);
|
|
350
|
-
|
|
351
|
-
for (let i = 0; i < length; i++) {
|
|
352
|
-
const storageKey = StoragePrototype.key.call(storage, i);
|
|
353
|
-
|
|
354
|
-
if (StringPrototype.startsWith.call(storageKey, prefix)) {
|
|
355
|
-
ArrayPrototype.push.call(keys, StringPrototype.slice.call(storageKey, prefix.length));
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
ArrayPrototype.push.apply(keys, ObjectKeys(target));
|
|
360
|
-
|
|
361
|
-
const set = new Set();
|
|
362
|
-
|
|
363
|
-
for (let i = 0; i < keys.length; i++) {
|
|
364
|
-
SetPrototype.add.call(set, keys[i]);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return ArrayPrototype.slice.call(set);
|
|
368
|
-
},
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
privates.set(proxy, privates.get(fake));
|
|
372
|
-
|
|
373
|
-
return proxy;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const toHide = new WeakMap();
|
|
377
|
-
for (const Type of [Function, Object, Array]) {
|
|
378
|
-
const create = (fallback) =>
|
|
379
|
-
function () {
|
|
380
|
-
if (this instanceof FakeStorage) {
|
|
381
|
-
return '[object Storage]';
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (WeakMapPrototype.has.call(toHide, this)) {
|
|
385
|
-
return `function ${WeakMapPrototype.get.call(toHide, this)}() { [native code] }`;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return fallback.call(this);
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
const toString = create(Type.prototype.toString);
|
|
392
|
-
const toLocaleString = create(Type.prototype.toLocaleString);
|
|
393
|
-
|
|
394
|
-
WeakMapPrototype.set.call(toHide, toString, 'toString');
|
|
395
|
-
WeakMapPrototype.set.call(toHide, toLocaleString, 'toLocaleString');
|
|
396
|
-
|
|
397
|
-
Object.defineProperty(Type.prototype, 'toString', {
|
|
398
|
-
__proto__: null,
|
|
399
|
-
value: toString,
|
|
400
|
-
});
|
|
401
|
-
Object.defineProperty(Type.prototype, 'toLocaleString', {
|
|
402
|
-
__proto__: null,
|
|
403
|
-
value: toLocaleString,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// https://stackoverflow.com/q/30481516
|
|
408
|
-
try {
|
|
409
|
-
// We use sessionStorage as the underlying storage for localStorage.
|
|
410
|
-
// This way we do not have to worry about clean up.
|
|
411
|
-
const { sessionStorage } = globalThis;
|
|
412
|
-
|
|
413
|
-
const fakeLocalStorage = createStorage({ storage: sessionStorage, prefix: 'l.' });
|
|
414
|
-
const fakeSessionStorage = createStorage({ storage: sessionStorage, prefix: 's.' });
|
|
415
|
-
|
|
416
|
-
const getLocalStorage = function localStorage() {
|
|
417
|
-
return fakeLocalStorage;
|
|
418
|
-
};
|
|
419
|
-
const getSessionStorage = function sessionStorage() {
|
|
420
|
-
return fakeSessionStorage;
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
WeakMapPrototype.set.call(toHide, FakeStorage, 'Storage');
|
|
424
|
-
WeakMapPrototype.set.call(toHide, FakeStoragePrototype.key, 'key');
|
|
425
|
-
WeakMapPrototype.set.call(toHide, FakeStoragePrototype.getItem, 'getItem');
|
|
426
|
-
WeakMapPrototype.set.call(toHide, FakeStoragePrototype.setItem, 'setItem');
|
|
427
|
-
WeakMapPrototype.set.call(toHide, FakeStoragePrototype.removeItem, 'removeItem');
|
|
428
|
-
WeakMapPrototype.set.call(toHide, FakeStoragePrototype.clear, 'clear');
|
|
429
|
-
WeakMapPrototype.set.call(toHide, getLocalStorage, 'get localStorage');
|
|
430
|
-
WeakMapPrototype.set.call(toHide, getSessionStorage, 'get sessionStorage');
|
|
431
|
-
|
|
432
|
-
ObjectDefineProperties(window, {
|
|
433
|
-
__proto__: null,
|
|
434
|
-
Storage: {
|
|
435
|
-
__proto__: null,
|
|
436
|
-
value: FakeStorage,
|
|
437
|
-
configurable: true,
|
|
438
|
-
enumerable: false,
|
|
439
|
-
writable: true,
|
|
440
|
-
},
|
|
441
|
-
localStorage: {
|
|
442
|
-
__proto__: null,
|
|
443
|
-
configurable: true,
|
|
444
|
-
enumerable: true,
|
|
445
|
-
get: getLocalStorage,
|
|
446
|
-
set: undefined,
|
|
447
|
-
},
|
|
448
|
-
sessionStorage: {
|
|
449
|
-
__proto__: null,
|
|
450
|
-
configurable: true,
|
|
451
|
-
enumerable: true,
|
|
452
|
-
get: getSessionStorage,
|
|
453
|
-
set: undefined,
|
|
454
|
-
},
|
|
455
|
-
});
|
|
456
|
-
} catch (error) {
|
|
457
|
-
console.error(error);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
{
|
|
461
|
-
const { Document } = globalThis;
|
|
462
|
-
|
|
463
|
-
const realGetCookie = ObjectGetOwnPropertyDescriptor(Document.prototype, 'cookie').get;
|
|
464
|
-
const realSetCookie = ObjectGetOwnPropertyDescriptor(Document.prototype, 'cookie').set;
|
|
465
|
-
|
|
466
|
-
const getCookie = function cookie() {
|
|
467
|
-
try {
|
|
468
|
-
const cookies = StringSplitSafe(realGetCookie.call(this), '; ');
|
|
469
|
-
const filtered = ArrayPrototype.filter.call(cookies, (cookie) =>
|
|
470
|
-
StringPrototype.startsWith.call(cookie, tabPrefix),
|
|
471
|
-
);
|
|
472
|
-
const mapped = ArrayPrototype.map.call(filtered, (cookie) => {
|
|
473
|
-
const result = StringPrototype.slice.call(cookie, tabPrefix.length);
|
|
474
|
-
|
|
475
|
-
if (result[0] === '=') {
|
|
476
|
-
return StringPrototype.slice.call(result, 1);
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
return result;
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
return ArrayPrototype.join.call(mapped, '; ');
|
|
483
|
-
} catch (error) {
|
|
484
|
-
throw fixStack(error);
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
const setCookie = function cookie(cookieString) {
|
|
489
|
-
cookieString = StringPrototype.trimStart.call(String(cookieString));
|
|
490
|
-
|
|
491
|
-
const delimiterIndex = StringPrototype.indexOf.call(cookieString, ';');
|
|
492
|
-
const equalsIndex = StringPrototype.indexOf.call(cookieString, '=');
|
|
493
|
-
if (equalsIndex === -1 || (delimiterIndex !== -1 && equalsIndex > delimiterIndex)) {
|
|
494
|
-
cookieString = `=${cookieString}`;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
try {
|
|
498
|
-
realSetCookie.call(this, tabPrefix + cookieString);
|
|
499
|
-
} catch (error) {
|
|
500
|
-
throw fixStack(error);
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
WeakMapPrototype.set.call(toHide, getCookie, 'get cookie');
|
|
505
|
-
WeakMapPrototype.set.call(toHide, setCookie, 'set cookie');
|
|
506
|
-
|
|
507
|
-
ObjectDefineProperty(Document.prototype, 'cookie', {
|
|
508
|
-
__proto__: null,
|
|
509
|
-
configurable: true,
|
|
510
|
-
enumerable: true,
|
|
511
|
-
get: getCookie,
|
|
512
|
-
set: setCookie,
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
{
|
|
517
|
-
const openDatabase = function open(name) {
|
|
518
|
-
try {
|
|
519
|
-
return IDBFactoryPrototype.open.call(this, tabPrefix + name);
|
|
520
|
-
} catch (error) {
|
|
521
|
-
throw fixStack(error);
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
const deleteDatabase = function deleteDatabase(name) {
|
|
526
|
-
try {
|
|
527
|
-
return IDBFactoryPrototype.deleteDatabase.call(this, tabPrefix + name);
|
|
528
|
-
} catch (error) {
|
|
529
|
-
throw fixStack(error);
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
|
|
533
|
-
const databaseName = function name() {
|
|
534
|
-
try {
|
|
535
|
-
return StringPrototype.slice.call(IDBDatabasePrototype.name.get.call(this), tabPrefix.length);
|
|
536
|
-
} catch (error) {
|
|
537
|
-
throw fixStack(error);
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
WeakMapPrototype.set.call(toHide, openDatabase, 'open');
|
|
542
|
-
WeakMapPrototype.set.call(toHide, deleteDatabase, 'deleteDatabase');
|
|
543
|
-
WeakMapPrototype.set.call(toHide, databaseName, 'get name');
|
|
544
|
-
|
|
545
|
-
ObjectDefineProperties(IDBFactory.prototype, {
|
|
546
|
-
__proto__: null,
|
|
547
|
-
open: {
|
|
548
|
-
__proto__: null,
|
|
549
|
-
writable: true,
|
|
550
|
-
configurable: true,
|
|
551
|
-
enumerable: true,
|
|
552
|
-
value: openDatabase,
|
|
553
|
-
},
|
|
554
|
-
deleteDatabase: {
|
|
555
|
-
__proto__: null,
|
|
556
|
-
writable: true,
|
|
557
|
-
configurable: true,
|
|
558
|
-
enumerable: true,
|
|
559
|
-
value: deleteDatabase,
|
|
560
|
-
},
|
|
561
|
-
name: {
|
|
562
|
-
__proto__: null,
|
|
563
|
-
configurable: true,
|
|
564
|
-
enumerable: true,
|
|
565
|
-
get: databaseName,
|
|
566
|
-
set: undefined,
|
|
567
|
-
},
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
{
|
|
572
|
-
ObjectDefineProperty(window, 'BroadcastChannel', {
|
|
573
|
-
__proto__: null,
|
|
574
|
-
configurable: true,
|
|
575
|
-
enumerable: false,
|
|
576
|
-
writable: true,
|
|
577
|
-
value: new Proxy(BroadcastChannel, {
|
|
578
|
-
__proto__: null,
|
|
579
|
-
construct: (Target, name) => {
|
|
580
|
-
return new Target(tabPrefix + name);
|
|
581
|
-
},
|
|
582
|
-
}),
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
WeakMapPrototype.set.call(toHide, window.BroadcastChannel, 'BroadcastChannel');
|
|
586
|
-
|
|
587
|
-
const getBroadcastChannelName = ObjectGetOwnPropertyDescriptor(BroadcastChannel.prototype, 'name').get;
|
|
588
|
-
const broadcastChannelName = function name() {
|
|
589
|
-
try {
|
|
590
|
-
const realName = getBroadcastChannelName.call(this);
|
|
591
|
-
|
|
592
|
-
if (StringPrototype.startsWith.call(realName, tabPrefix)) {
|
|
593
|
-
return StringPrototype.slice.call(realName, tabPrefix.length);
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
return realName;
|
|
597
|
-
} catch (error) {
|
|
598
|
-
throw fixStack(error);
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
WeakMapPrototype.set.call(toHide, broadcastChannelName, 'get name');
|
|
603
|
-
|
|
604
|
-
ObjectDefineProperty(BroadcastChannel.prototype, 'name', {
|
|
605
|
-
__proto__: null,
|
|
606
|
-
configurable: true,
|
|
607
|
-
enumerable: true,
|
|
608
|
-
get: broadcastChannelName,
|
|
609
|
-
set: undefined,
|
|
610
|
-
});
|
|
611
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"manifest_version": 2,
|
|
3
|
-
"name": "Tab as a Container",
|
|
4
|
-
"version": "1.0.0",
|
|
5
|
-
"background": {
|
|
6
|
-
"scripts": ["background.js"],
|
|
7
|
-
"persistent": true
|
|
8
|
-
},
|
|
9
|
-
"permissions": [
|
|
10
|
-
"webRequest",
|
|
11
|
-
"webRequestBlocking",
|
|
12
|
-
"webNavigation",
|
|
13
|
-
"tabs",
|
|
14
|
-
"cookies",
|
|
15
|
-
"privacy",
|
|
16
|
-
"proxy",
|
|
17
|
-
"<all_urls>"
|
|
18
|
-
],
|
|
19
|
-
"web_accessible_resources": ["content.js"],
|
|
20
|
-
"incognito": "not_allowed"
|
|
21
|
-
}
|