untiktok-api 1.0.0
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/LICENSE +21 -0
- package/LICENSE.txt +21 -0
- package/README.md +80 -0
- package/dist/api/comment.d.ts +42 -0
- package/dist/api/comment.js +84 -0
- package/dist/api/hashtag.d.ts +52 -0
- package/dist/api/hashtag.js +118 -0
- package/dist/api/playlist.d.ts +53 -0
- package/dist/api/playlist.js +112 -0
- package/dist/api/search.d.ts +38 -0
- package/dist/api/search.js +98 -0
- package/dist/api/sound.d.ts +57 -0
- package/dist/api/sound.js +133 -0
- package/dist/api/trending.d.ts +21 -0
- package/dist/api/trending.js +52 -0
- package/dist/api/user.d.ts +187 -0
- package/dist/api/user.js +498 -0
- package/dist/api/video.d.ts +119 -0
- package/dist/api/video.js +399 -0
- package/dist/exceptions.d.ts +24 -0
- package/dist/exceptions.js +61 -0
- package/dist/helpers.d.ts +23 -0
- package/dist/helpers.js +66 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +35 -0
- package/dist/stealth/index.d.ts +70 -0
- package/dist/stealth/index.js +128 -0
- package/dist/stealth/js/chrome_app.d.ts +1 -0
- package/dist/stealth/js/chrome_app.js +27 -0
- package/dist/stealth/js/chrome_csi.d.ts +1 -0
- package/dist/stealth/js/chrome_csi.js +14 -0
- package/dist/stealth/js/chrome_hairline.d.ts +1 -0
- package/dist/stealth/js/chrome_hairline.js +16 -0
- package/dist/stealth/js/chrome_load_times.d.ts +1 -0
- package/dist/stealth/js/chrome_load_times.js +28 -0
- package/dist/stealth/js/chrome_runtime_script.d.ts +1 -0
- package/dist/stealth/js/chrome_runtime_script.js +84 -0
- package/dist/stealth/js/generate_magic_arrays.d.ts +1 -0
- package/dist/stealth/js/generate_magic_arrays.js +28 -0
- package/dist/stealth/js/iframe_contentWindow.d.ts +1 -0
- package/dist/stealth/js/iframe_contentWindow.js +22 -0
- package/dist/stealth/js/media_codecs.d.ts +1 -0
- package/dist/stealth/js/media_codecs.js +16 -0
- package/dist/stealth/js/navigator_hardwareConcurrency.d.ts +1 -0
- package/dist/stealth/js/navigator_hardwareConcurrency.js +6 -0
- package/dist/stealth/js/navigator_languages.d.ts +1 -0
- package/dist/stealth/js/navigator_languages.js +6 -0
- package/dist/stealth/js/navigator_permissions.d.ts +1 -0
- package/dist/stealth/js/navigator_permissions.js +11 -0
- package/dist/stealth/js/navigator_platform.d.ts +1 -0
- package/dist/stealth/js/navigator_platform.js +8 -0
- package/dist/stealth/js/navigator_plugins_script.d.ts +1 -0
- package/dist/stealth/js/navigator_plugins_script.js +37 -0
- package/dist/stealth/js/navigator_userAgent_script.d.ts +1 -0
- package/dist/stealth/js/navigator_userAgent_script.js +8 -0
- package/dist/stealth/js/navigator_vendor_script.d.ts +1 -0
- package/dist/stealth/js/navigator_vendor_script.js +6 -0
- package/dist/stealth/js/utils_script.d.ts +1 -0
- package/dist/stealth/js/utils_script.js +119 -0
- package/dist/stealth/js/webgl_vendor_script.d.ts +1 -0
- package/dist/stealth/js/webgl_vendor_script.js +16 -0
- package/dist/stealth/js/window_outerdimensions.d.ts +1 -0
- package/dist/stealth/js/window_outerdimensions.js +9 -0
- package/dist/tiktok.d.ts +96 -0
- package/dist/tiktok.js +758 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.js +6 -0
- package/package.json +41 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Page } from "playwright";
|
|
2
|
+
export interface StealthConfigOptions {
|
|
3
|
+
webdriver?: boolean;
|
|
4
|
+
webglVendor?: boolean;
|
|
5
|
+
chromeApp?: boolean;
|
|
6
|
+
chromeCsi?: boolean;
|
|
7
|
+
chromeLoadTimes?: boolean;
|
|
8
|
+
chromeRuntime?: boolean;
|
|
9
|
+
iframeContentWindow?: boolean;
|
|
10
|
+
mediaCodecs?: boolean;
|
|
11
|
+
navigatorHardwareConcurrency?: number;
|
|
12
|
+
navigatorLanguages?: boolean;
|
|
13
|
+
navigatorPermissions?: boolean;
|
|
14
|
+
navigatorPlatform?: boolean;
|
|
15
|
+
navigatorPlugins?: boolean;
|
|
16
|
+
navigatorUserAgent?: boolean;
|
|
17
|
+
navigatorVendor?: boolean;
|
|
18
|
+
outerdimensions?: boolean;
|
|
19
|
+
hairline?: boolean;
|
|
20
|
+
vendor?: string;
|
|
21
|
+
renderer?: string;
|
|
22
|
+
navVendor?: string;
|
|
23
|
+
navUserAgent?: string | null;
|
|
24
|
+
navPlatform?: string | null;
|
|
25
|
+
languages?: string[];
|
|
26
|
+
runOnInsecureOrigins?: boolean | null;
|
|
27
|
+
}
|
|
28
|
+
export declare class StealthConfig {
|
|
29
|
+
webdriver: boolean;
|
|
30
|
+
webglVendor: boolean;
|
|
31
|
+
chromeApp: boolean;
|
|
32
|
+
chromeCsi: boolean;
|
|
33
|
+
chromeLoadTimes: boolean;
|
|
34
|
+
chromeRuntime: boolean;
|
|
35
|
+
iframeContentWindow: boolean;
|
|
36
|
+
mediaCodecs: boolean;
|
|
37
|
+
navigatorHardwareConcurrency: number;
|
|
38
|
+
navigatorLanguages: boolean;
|
|
39
|
+
navigatorPermissions: boolean;
|
|
40
|
+
navigatorPlatform: boolean;
|
|
41
|
+
navigatorPlugins: boolean;
|
|
42
|
+
navigatorUserAgent: boolean;
|
|
43
|
+
navigatorVendor: boolean;
|
|
44
|
+
outerdimensions: boolean;
|
|
45
|
+
hairline: boolean;
|
|
46
|
+
vendor: string;
|
|
47
|
+
renderer: string;
|
|
48
|
+
navVendor: string;
|
|
49
|
+
navUserAgent: string | null;
|
|
50
|
+
navPlatform: string | null;
|
|
51
|
+
languages: string[];
|
|
52
|
+
runOnInsecureOrigins: boolean | null;
|
|
53
|
+
constructor(opts?: StealthConfigOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Yields all enabled stealth script strings in the correct order.
|
|
56
|
+
* Mirrors Python's `enabled_scripts` generator property.
|
|
57
|
+
*/
|
|
58
|
+
enabledScripts(): Generator<string>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Inject stealth scripts into a Playwright page to evade bot detection.
|
|
62
|
+
* Mirrors Python's `stealth_async(page, config)`.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { stealthAsync } from './stealth';
|
|
67
|
+
* await stealthAsync(page);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function stealthAsync(page: Page, config?: StealthConfig): Promise<void>;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// stealth/index.ts
|
|
4
|
+
// Mirrors TikTokApi/stealth/stealth.py + all JS scripts
|
|
5
|
+
//
|
|
6
|
+
// Injects anti-bot JavaScript into Playwright pages to make
|
|
7
|
+
// headless Chromium look like a real browser.
|
|
8
|
+
// ============================================================
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StealthConfig = void 0;
|
|
11
|
+
exports.stealthAsync = stealthAsync;
|
|
12
|
+
const chrome_app_1 = require("./js/chrome_app");
|
|
13
|
+
const chrome_csi_1 = require("./js/chrome_csi");
|
|
14
|
+
const chrome_hairline_1 = require("./js/chrome_hairline");
|
|
15
|
+
const chrome_load_times_1 = require("./js/chrome_load_times");
|
|
16
|
+
const generate_magic_arrays_1 = require("./js/generate_magic_arrays");
|
|
17
|
+
const iframe_contentWindow_1 = require("./js/iframe_contentWindow");
|
|
18
|
+
const media_codecs_1 = require("./js/media_codecs");
|
|
19
|
+
const navigator_languages_1 = require("./js/navigator_languages");
|
|
20
|
+
const navigator_permissions_1 = require("./js/navigator_permissions");
|
|
21
|
+
const navigator_platform_1 = require("./js/navigator_platform");
|
|
22
|
+
const navigator_plugins_script_1 = require("./js/navigator_plugins_script");
|
|
23
|
+
const navigator_userAgent_script_1 = require("./js/navigator_userAgent_script");
|
|
24
|
+
const navigator_vendor_script_1 = require("./js/navigator_vendor_script");
|
|
25
|
+
const webgl_vendor_script_1 = require("./js/webgl_vendor_script");
|
|
26
|
+
const window_outerdimensions_1 = require("./js/window_outerdimensions");
|
|
27
|
+
const utils_script_1 = require("./js/utils_script");
|
|
28
|
+
const chrome_runtime_script_1 = require("./js/chrome_runtime_script");
|
|
29
|
+
class StealthConfig {
|
|
30
|
+
constructor(opts = {}) {
|
|
31
|
+
this.webdriver = opts.webdriver ?? true;
|
|
32
|
+
this.webglVendor = opts.webglVendor ?? true;
|
|
33
|
+
this.chromeApp = opts.chromeApp ?? true;
|
|
34
|
+
this.chromeCsi = opts.chromeCsi ?? true;
|
|
35
|
+
this.chromeLoadTimes = opts.chromeLoadTimes ?? true;
|
|
36
|
+
this.chromeRuntime = opts.chromeRuntime ?? true;
|
|
37
|
+
this.iframeContentWindow = opts.iframeContentWindow ?? true;
|
|
38
|
+
this.mediaCodecs = opts.mediaCodecs ?? true;
|
|
39
|
+
this.navigatorHardwareConcurrency = opts.navigatorHardwareConcurrency ?? 4;
|
|
40
|
+
this.navigatorLanguages = opts.navigatorLanguages ?? false;
|
|
41
|
+
this.navigatorPermissions = opts.navigatorPermissions ?? true;
|
|
42
|
+
this.navigatorPlatform = opts.navigatorPlatform ?? true;
|
|
43
|
+
this.navigatorPlugins = opts.navigatorPlugins ?? true;
|
|
44
|
+
this.navigatorUserAgent = opts.navigatorUserAgent ?? false;
|
|
45
|
+
this.navigatorVendor = opts.navigatorVendor ?? false;
|
|
46
|
+
this.outerdimensions = opts.outerdimensions ?? true;
|
|
47
|
+
this.hairline = opts.hairline ?? true;
|
|
48
|
+
this.vendor = opts.vendor ?? "Intel Inc.";
|
|
49
|
+
this.renderer = opts.renderer ?? "Intel Iris OpenGL Engine";
|
|
50
|
+
this.navVendor = opts.navVendor ?? "Google Inc.";
|
|
51
|
+
this.navUserAgent = opts.navUserAgent ?? null;
|
|
52
|
+
this.navPlatform = opts.navPlatform ?? null;
|
|
53
|
+
this.languages = opts.languages ?? ["en-US", "en"];
|
|
54
|
+
this.runOnInsecureOrigins = opts.runOnInsecureOrigins ?? null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Yields all enabled stealth script strings in the correct order.
|
|
58
|
+
* Mirrors Python's `enabled_scripts` generator property.
|
|
59
|
+
*/
|
|
60
|
+
*enabledScripts() {
|
|
61
|
+
const opts = JSON.stringify({
|
|
62
|
+
webgl_vendor: this.vendor,
|
|
63
|
+
webgl_renderer: this.renderer,
|
|
64
|
+
navigator_vendor: this.navVendor,
|
|
65
|
+
navigator_platform: this.navPlatform,
|
|
66
|
+
navigator_user_agent: this.navUserAgent,
|
|
67
|
+
languages: this.languages,
|
|
68
|
+
runOnInsecureOrigins: this.runOnInsecureOrigins,
|
|
69
|
+
navigator_hardware_concurrency: this.navigatorHardwareConcurrency,
|
|
70
|
+
});
|
|
71
|
+
yield `const opts = ${opts}`;
|
|
72
|
+
yield utils_script_1.utils_script; // utils must come first
|
|
73
|
+
yield generate_magic_arrays_1.generate_magic_arrays; // needed by navigator_plugins
|
|
74
|
+
if (this.chromeApp)
|
|
75
|
+
yield chrome_app_1.chrome_app;
|
|
76
|
+
if (this.chromeCsi)
|
|
77
|
+
yield chrome_csi_1.chrome_csi;
|
|
78
|
+
if (this.hairline)
|
|
79
|
+
yield chrome_hairline_1.chrome_hairline;
|
|
80
|
+
if (this.chromeLoadTimes)
|
|
81
|
+
yield chrome_load_times_1.chrome_load_times;
|
|
82
|
+
// chrome_runtime is defined inline below (it's long and uses opts)
|
|
83
|
+
if (this.chromeRuntime)
|
|
84
|
+
yield chrome_runtime_script_1.chrome_runtime_script;
|
|
85
|
+
if (this.iframeContentWindow)
|
|
86
|
+
yield iframe_contentWindow_1.iframe_contentWindow;
|
|
87
|
+
if (this.mediaCodecs)
|
|
88
|
+
yield media_codecs_1.media_codecs;
|
|
89
|
+
if (this.navigatorLanguages)
|
|
90
|
+
yield navigator_languages_1.navigator_languages;
|
|
91
|
+
if (this.navigatorPermissions)
|
|
92
|
+
yield navigator_permissions_1.navigator_permissions;
|
|
93
|
+
if (this.navigatorPlatform)
|
|
94
|
+
yield navigator_platform_1.navigator_platform;
|
|
95
|
+
if (this.navigatorPlugins)
|
|
96
|
+
yield navigator_plugins_script_1.navigator_plugins_script;
|
|
97
|
+
if (this.navigatorUserAgent)
|
|
98
|
+
yield navigator_userAgent_script_1.navigator_userAgent_script;
|
|
99
|
+
if (this.navigatorVendor)
|
|
100
|
+
yield navigator_vendor_script_1.navigator_vendor_script;
|
|
101
|
+
if (this.webdriver)
|
|
102
|
+
yield `delete Object.getPrototypeOf(navigator).webdriver`;
|
|
103
|
+
if (this.outerdimensions)
|
|
104
|
+
yield window_outerdimensions_1.window_outerdimensions;
|
|
105
|
+
if (this.webglVendor)
|
|
106
|
+
yield webgl_vendor_script_1.webgl_vendor_script;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.StealthConfig = StealthConfig;
|
|
110
|
+
// ---------------------------------------------------------------------------
|
|
111
|
+
// stealth_async — main export (mirrors Python's stealth_async function)
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
/**
|
|
114
|
+
* Inject stealth scripts into a Playwright page to evade bot detection.
|
|
115
|
+
* Mirrors Python's `stealth_async(page, config)`.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* import { stealthAsync } from './stealth';
|
|
120
|
+
* await stealthAsync(page);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
async function stealthAsync(page, config) {
|
|
124
|
+
const cfg = config ?? new StealthConfig();
|
|
125
|
+
for (const script of cfg.enabledScripts()) {
|
|
126
|
+
await page.addInitScript(script);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chrome_app = "\nif (!window.chrome) {\n Object.defineProperty(window, 'chrome', {\n writable: true, enumerable: true, configurable: false, value: {}\n })\n}\nif (!('app' in window.chrome)) {\n const makeError = {\n ErrorInInvocation: fn => {\n const err = new TypeError(`Error in invocation of app.${fn}()`)\n return utils.stripErrorWithAnchor(err, `at ${fn} (eval at <anonymous>`)\n }\n }\n const APP_STATIC_DATA = JSON.parse(`{\"isInstalled\":false,\"InstallState\":{\"DISABLED\":\"disabled\",\"INSTALLED\":\"installed\",\"NOT_INSTALLED\":\"not_installed\"},\"RunningState\":{\"CANNOT_RUN\":\"cannot_run\",\"READY_TO_RUN\":\"ready_to_run\",\"RUNNING\":\"running\"}}`)\n window.chrome.app = {\n ...APP_STATIC_DATA,\n get isInstalled() { return false },\n getDetails: function getDetails() { if (arguments.length) throw makeError.ErrorInInvocation('getDetails'); return null },\n getIsInstalled: function getIsInstalled() { if (arguments.length) throw makeError.ErrorInInvocation('getIsInstalled'); return false },\n runningState: function runningState() { if (arguments.length) throw makeError.ErrorInInvocation('runningState'); return 'cannot_run' }\n }\n utils.patchToStringNested(window.chrome.app)\n}\n";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chrome_app = void 0;
|
|
4
|
+
exports.chrome_app = `
|
|
5
|
+
if (!window.chrome) {
|
|
6
|
+
Object.defineProperty(window, 'chrome', {
|
|
7
|
+
writable: true, enumerable: true, configurable: false, value: {}
|
|
8
|
+
})
|
|
9
|
+
}
|
|
10
|
+
if (!('app' in window.chrome)) {
|
|
11
|
+
const makeError = {
|
|
12
|
+
ErrorInInvocation: fn => {
|
|
13
|
+
const err = new TypeError(\`Error in invocation of app.\${fn}()\`)
|
|
14
|
+
return utils.stripErrorWithAnchor(err, \`at \${fn} (eval at <anonymous>\`)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const APP_STATIC_DATA = JSON.parse(\`{"isInstalled":false,"InstallState":{"DISABLED":"disabled","INSTALLED":"installed","NOT_INSTALLED":"not_installed"},"RunningState":{"CANNOT_RUN":"cannot_run","READY_TO_RUN":"ready_to_run","RUNNING":"running"}}\`)
|
|
18
|
+
window.chrome.app = {
|
|
19
|
+
...APP_STATIC_DATA,
|
|
20
|
+
get isInstalled() { return false },
|
|
21
|
+
getDetails: function getDetails() { if (arguments.length) throw makeError.ErrorInInvocation('getDetails'); return null },
|
|
22
|
+
getIsInstalled: function getIsInstalled() { if (arguments.length) throw makeError.ErrorInInvocation('getIsInstalled'); return false },
|
|
23
|
+
runningState: function runningState() { if (arguments.length) throw makeError.ErrorInInvocation('runningState'); return 'cannot_run' }
|
|
24
|
+
}
|
|
25
|
+
utils.patchToStringNested(window.chrome.app)
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chrome_csi = "\nif (!window.chrome) {\n Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })\n}\nif (!('csi' in window.chrome)) {\n window.chrome.csi = function() {\n return { onloadT: Date.now(), startE: Date.now(), pageT: Date.now() - performance.timing.navigationStart, tran: 15 }\n }\n utils.patchToString(window.chrome.csi)\n}\n";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chrome_csi = void 0;
|
|
4
|
+
exports.chrome_csi = `
|
|
5
|
+
if (!window.chrome) {
|
|
6
|
+
Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })
|
|
7
|
+
}
|
|
8
|
+
if (!('csi' in window.chrome)) {
|
|
9
|
+
window.chrome.csi = function() {
|
|
10
|
+
return { onloadT: Date.now(), startE: Date.now(), pageT: Date.now() - performance.timing.navigationStart, tran: 15 }
|
|
11
|
+
}
|
|
12
|
+
utils.patchToString(window.chrome.csi)
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chrome_hairline = "\nconst canvasContext = document.createElement('canvas').getContext('webgl')\nif (canvasContext) {\n const nativeGetParameter = WebGLRenderingContext.prototype.getParameter\n utils.replaceWithProxy(WebGLRenderingContext.prototype, 'getParameter', {\n apply: function(target, ctx, args) {\n const param = (args || [])[0]\n if (param === 37446) { return 0 }\n return utils.cache.Reflect.apply(target, ctx, args)\n }\n })\n}\n";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chrome_hairline = void 0;
|
|
4
|
+
exports.chrome_hairline = `
|
|
5
|
+
const canvasContext = document.createElement('canvas').getContext('webgl')
|
|
6
|
+
if (canvasContext) {
|
|
7
|
+
const nativeGetParameter = WebGLRenderingContext.prototype.getParameter
|
|
8
|
+
utils.replaceWithProxy(WebGLRenderingContext.prototype, 'getParameter', {
|
|
9
|
+
apply: function(target, ctx, args) {
|
|
10
|
+
const param = (args || [])[0]
|
|
11
|
+
if (param === 37446) { return 0 }
|
|
12
|
+
return utils.cache.Reflect.apply(target, ctx, args)
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chrome_load_times = "\nif (!window.chrome) {\n Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })\n}\nif (!('loadTimes' in window.chrome)) {\n const loadTime = Date.now() / 1000 - Math.random() * 20\n const startLoadTime = loadTime - Math.random() * 2\n const data = {\n get commitLoadTime() { return startLoadTime },\n get finishDocumentLoadTime() { return loadTime },\n get finishLoadTime() { return loadTime + Math.random() },\n get firstPaintAfterLoadTime() { return 0 },\n get firstPaintTime() { return startLoadTime + Math.random() * 2 },\n get navigationType() { return 'Other' },\n get npnNegotiatedProtocol() { return 'unknown' },\n get requestTime() { return startLoadTime - 0.01 },\n get startLoadTime() { return startLoadTime },\n get wasAlternateProtocolAvailable() { return false },\n get wasFetchedViaSpdy() { return false },\n get wasNpnNegotiated() { return false }\n }\n utils.replaceProperty(window.chrome, 'loadTimes', { value: function loadTimes() { return data } })\n utils.patchToString(window.chrome.loadTimes)\n}\n";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chrome_load_times = void 0;
|
|
4
|
+
exports.chrome_load_times = `
|
|
5
|
+
if (!window.chrome) {
|
|
6
|
+
Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })
|
|
7
|
+
}
|
|
8
|
+
if (!('loadTimes' in window.chrome)) {
|
|
9
|
+
const loadTime = Date.now() / 1000 - Math.random() * 20
|
|
10
|
+
const startLoadTime = loadTime - Math.random() * 2
|
|
11
|
+
const data = {
|
|
12
|
+
get commitLoadTime() { return startLoadTime },
|
|
13
|
+
get finishDocumentLoadTime() { return loadTime },
|
|
14
|
+
get finishLoadTime() { return loadTime + Math.random() },
|
|
15
|
+
get firstPaintAfterLoadTime() { return 0 },
|
|
16
|
+
get firstPaintTime() { return startLoadTime + Math.random() * 2 },
|
|
17
|
+
get navigationType() { return 'Other' },
|
|
18
|
+
get npnNegotiatedProtocol() { return 'unknown' },
|
|
19
|
+
get requestTime() { return startLoadTime - 0.01 },
|
|
20
|
+
get startLoadTime() { return startLoadTime },
|
|
21
|
+
get wasAlternateProtocolAvailable() { return false },
|
|
22
|
+
get wasFetchedViaSpdy() { return false },
|
|
23
|
+
get wasNpnNegotiated() { return false }
|
|
24
|
+
}
|
|
25
|
+
utils.replaceProperty(window.chrome, 'loadTimes', { value: function loadTimes() { return data } })
|
|
26
|
+
utils.patchToString(window.chrome.loadTimes)
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chrome_runtime_script = "\nconst STATIC_DATA = {\"OnInstalledReason\":{\"CHROME_UPDATE\":\"chrome_update\",\"INSTALL\":\"install\",\"SHARED_MODULE_UPDATE\":\"shared_module_update\",\"UPDATE\":\"update\"},\"OnRestartRequiredReason\":{\"APP_UPDATE\":\"app_update\",\"OS_UPDATE\":\"os_update\",\"PERIODIC\":\"periodic\"},\"PlatformArch\":{\"ARM\":\"arm\",\"ARM64\":\"arm64\",\"MIPS\":\"mips\",\"MIPS64\":\"mips64\",\"X86_32\":\"x86-32\",\"X86_64\":\"x86-64\"},\"PlatformNaclArch\":{\"ARM\":\"arm\",\"MIPS\":\"mips\",\"MIPS64\":\"mips64\",\"X86_32\":\"x86-32\",\"X86_64\":\"x86-64\"},\"PlatformOs\":{\"ANDROID\":\"android\",\"CROS\":\"cros\",\"LINUX\":\"linux\",\"MAC\":\"mac\",\"OPENBSD\":\"openbsd\",\"WIN\":\"win\"},\"RequestUpdateCheckStatus\":{\"NO_UPDATE\":\"no_update\",\"THROTTLED\":\"throttled\",\"UPDATE_AVAILABLE\":\"update_available\"}}\nif (!window.chrome) {\n Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })\n}\nconst existsAlready = 'runtime' in window.chrome\nconst isNotSecure = !window.location.protocol.startsWith('https')\nif (!(existsAlready || (isNotSecure && !opts.runOnInsecureOrigins))) {\n window.chrome.runtime = {\n ...STATIC_DATA,\n get id() { return undefined },\n connect: null,\n sendMessage: null\n }\n const makeCustomRuntimeErrors = (preamble, method, extensionId) => ({\n NoMatchingSignature: new TypeError(preamble + 'No matching signature.'),\n MustSpecifyExtensionID: new TypeError(preamble + method + ' called from a webpage must specify an Extension ID (string) for its first argument.'),\n InvalidExtensionID: new TypeError(preamble + \"Invalid extension id: '\" + extensionId + \"'\")\n })\n const isValidExtensionID = str => str.length === 32 && str.toLowerCase().match(/^[a-p]+$/)\n const sendMessageHandler = {\n apply: function(target, ctx, args) {\n const [extensionId, options, responseCallback] = args || []\n const errorPreamble = 'Error in invocation of runtime.sendMessage(optional string extensionId, any message, optional object options, optional function responseCallback): '\n const Errors = makeCustomRuntimeErrors(errorPreamble, 'chrome.runtime.sendMessage()', extensionId)\n const noArguments = args.length === 0, tooManyArguments = args.length > 4\n const incorrectOptions = options && typeof options !== 'object'\n const incorrectResponseCallback = responseCallback && typeof responseCallback !== 'function'\n if (noArguments || tooManyArguments || incorrectOptions || incorrectResponseCallback) throw Errors.NoMatchingSignature\n if (args.length < 2) throw Errors.MustSpecifyExtensionID\n if (typeof extensionId !== 'string') throw Errors.NoMatchingSignature\n if (!isValidExtensionID(extensionId)) throw Errors.InvalidExtensionID\n return undefined\n }\n }\n utils.mockWithProxy(window.chrome.runtime, 'sendMessage', function sendMessage() {}, sendMessageHandler)\n const connectHandler = {\n apply: function(target, ctx, args) {\n const [extensionId, connectInfo] = args || []\n const errorPreamble = 'Error in invocation of runtime.connect(optional string extensionId, optional object connectInfo): '\n const Errors = makeCustomRuntimeErrors(errorPreamble, 'chrome.runtime.connect()', extensionId)\n const noArguments = args.length === 0, emptyStringArgument = args.length === 1 && extensionId === ''\n if (noArguments || emptyStringArgument) throw Errors.MustSpecifyExtensionID\n const tooManyArguments = args.length > 2, incorrectConnectInfoType = connectInfo && typeof connectInfo !== 'object'\n if (tooManyArguments || incorrectConnectInfoType) throw Errors.NoMatchingSignature\n const extensionIdIsString = typeof extensionId === 'string'\n if (extensionIdIsString && extensionId === '') throw Errors.MustSpecifyExtensionID\n if (extensionIdIsString && !isValidExtensionID(extensionId)) throw Errors.InvalidExtensionID\n const validateConnectInfo = ci => {\n if (args.length > 1) throw Errors.NoMatchingSignature\n if (Object.keys(ci).length === 0) throw Errors.MustSpecifyExtensionID\n Object.entries(ci).forEach(([k, v]) => {\n const isExpected = ['name', 'includeTlsChannelId'].includes(k)\n if (!isExpected) throw new TypeError(errorPreamble + \"Unexpected property: '\" + k + \"'.\")\n if (k === 'name' && typeof v !== 'string') throw TypeError(errorPreamble + \"Error at property '\" + k + \"': Invalid type: expected string, found \" + typeof v + \".\")\n if (k === 'includeTlsChannelId' && typeof v !== 'boolean') throw TypeError(errorPreamble + \"Error at property '\" + k + \"': Invalid type: expected boolean, found \" + typeof v + \".\")\n })\n }\n if (typeof extensionId === 'object') { validateConnectInfo(extensionId); throw Errors.MustSpecifyExtensionID }\n return utils.patchToStringNested(makeConnectResponse())\n }\n }\n utils.mockWithProxy(window.chrome.runtime, 'connect', function connect() {}, connectHandler)\n function makeConnectResponse() {\n const onSomething = () => ({\n addListener: function addListener() {}, dispatch: function dispatch() {},\n hasListener: function hasListener() {}, hasListeners: function hasListeners() { return false },\n removeListener: function removeListener() {}\n })\n return {\n name: '', sender: undefined,\n disconnect: function disconnect() {},\n onDisconnect: onSomething(), onMessage: onSomething(),\n postMessage: function postMessage() {\n if (!arguments.length) throw new TypeError('Insufficient number of arguments.')\n throw new Error('Attempting to use a disconnected port object')\n }\n }\n }\n}\n";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chrome_runtime_script = void 0;
|
|
4
|
+
exports.chrome_runtime_script = `
|
|
5
|
+
const STATIC_DATA = {"OnInstalledReason":{"CHROME_UPDATE":"chrome_update","INSTALL":"install","SHARED_MODULE_UPDATE":"shared_module_update","UPDATE":"update"},"OnRestartRequiredReason":{"APP_UPDATE":"app_update","OS_UPDATE":"os_update","PERIODIC":"periodic"},"PlatformArch":{"ARM":"arm","ARM64":"arm64","MIPS":"mips","MIPS64":"mips64","X86_32":"x86-32","X86_64":"x86-64"},"PlatformNaclArch":{"ARM":"arm","MIPS":"mips","MIPS64":"mips64","X86_32":"x86-32","X86_64":"x86-64"},"PlatformOs":{"ANDROID":"android","CROS":"cros","LINUX":"linux","MAC":"mac","OPENBSD":"openbsd","WIN":"win"},"RequestUpdateCheckStatus":{"NO_UPDATE":"no_update","THROTTLED":"throttled","UPDATE_AVAILABLE":"update_available"}}
|
|
6
|
+
if (!window.chrome) {
|
|
7
|
+
Object.defineProperty(window, 'chrome', { writable: true, enumerable: true, configurable: false, value: {} })
|
|
8
|
+
}
|
|
9
|
+
const existsAlready = 'runtime' in window.chrome
|
|
10
|
+
const isNotSecure = !window.location.protocol.startsWith('https')
|
|
11
|
+
if (!(existsAlready || (isNotSecure && !opts.runOnInsecureOrigins))) {
|
|
12
|
+
window.chrome.runtime = {
|
|
13
|
+
...STATIC_DATA,
|
|
14
|
+
get id() { return undefined },
|
|
15
|
+
connect: null,
|
|
16
|
+
sendMessage: null
|
|
17
|
+
}
|
|
18
|
+
const makeCustomRuntimeErrors = (preamble, method, extensionId) => ({
|
|
19
|
+
NoMatchingSignature: new TypeError(preamble + 'No matching signature.'),
|
|
20
|
+
MustSpecifyExtensionID: new TypeError(preamble + method + ' called from a webpage must specify an Extension ID (string) for its first argument.'),
|
|
21
|
+
InvalidExtensionID: new TypeError(preamble + "Invalid extension id: '" + extensionId + "'")
|
|
22
|
+
})
|
|
23
|
+
const isValidExtensionID = str => str.length === 32 && str.toLowerCase().match(/^[a-p]+$/)
|
|
24
|
+
const sendMessageHandler = {
|
|
25
|
+
apply: function(target, ctx, args) {
|
|
26
|
+
const [extensionId, options, responseCallback] = args || []
|
|
27
|
+
const errorPreamble = 'Error in invocation of runtime.sendMessage(optional string extensionId, any message, optional object options, optional function responseCallback): '
|
|
28
|
+
const Errors = makeCustomRuntimeErrors(errorPreamble, 'chrome.runtime.sendMessage()', extensionId)
|
|
29
|
+
const noArguments = args.length === 0, tooManyArguments = args.length > 4
|
|
30
|
+
const incorrectOptions = options && typeof options !== 'object'
|
|
31
|
+
const incorrectResponseCallback = responseCallback && typeof responseCallback !== 'function'
|
|
32
|
+
if (noArguments || tooManyArguments || incorrectOptions || incorrectResponseCallback) throw Errors.NoMatchingSignature
|
|
33
|
+
if (args.length < 2) throw Errors.MustSpecifyExtensionID
|
|
34
|
+
if (typeof extensionId !== 'string') throw Errors.NoMatchingSignature
|
|
35
|
+
if (!isValidExtensionID(extensionId)) throw Errors.InvalidExtensionID
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
utils.mockWithProxy(window.chrome.runtime, 'sendMessage', function sendMessage() {}, sendMessageHandler)
|
|
40
|
+
const connectHandler = {
|
|
41
|
+
apply: function(target, ctx, args) {
|
|
42
|
+
const [extensionId, connectInfo] = args || []
|
|
43
|
+
const errorPreamble = 'Error in invocation of runtime.connect(optional string extensionId, optional object connectInfo): '
|
|
44
|
+
const Errors = makeCustomRuntimeErrors(errorPreamble, 'chrome.runtime.connect()', extensionId)
|
|
45
|
+
const noArguments = args.length === 0, emptyStringArgument = args.length === 1 && extensionId === ''
|
|
46
|
+
if (noArguments || emptyStringArgument) throw Errors.MustSpecifyExtensionID
|
|
47
|
+
const tooManyArguments = args.length > 2, incorrectConnectInfoType = connectInfo && typeof connectInfo !== 'object'
|
|
48
|
+
if (tooManyArguments || incorrectConnectInfoType) throw Errors.NoMatchingSignature
|
|
49
|
+
const extensionIdIsString = typeof extensionId === 'string'
|
|
50
|
+
if (extensionIdIsString && extensionId === '') throw Errors.MustSpecifyExtensionID
|
|
51
|
+
if (extensionIdIsString && !isValidExtensionID(extensionId)) throw Errors.InvalidExtensionID
|
|
52
|
+
const validateConnectInfo = ci => {
|
|
53
|
+
if (args.length > 1) throw Errors.NoMatchingSignature
|
|
54
|
+
if (Object.keys(ci).length === 0) throw Errors.MustSpecifyExtensionID
|
|
55
|
+
Object.entries(ci).forEach(([k, v]) => {
|
|
56
|
+
const isExpected = ['name', 'includeTlsChannelId'].includes(k)
|
|
57
|
+
if (!isExpected) throw new TypeError(errorPreamble + "Unexpected property: '" + k + "'.")
|
|
58
|
+
if (k === 'name' && typeof v !== 'string') throw TypeError(errorPreamble + "Error at property '" + k + "': Invalid type: expected string, found " + typeof v + ".")
|
|
59
|
+
if (k === 'includeTlsChannelId' && typeof v !== 'boolean') throw TypeError(errorPreamble + "Error at property '" + k + "': Invalid type: expected boolean, found " + typeof v + ".")
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
if (typeof extensionId === 'object') { validateConnectInfo(extensionId); throw Errors.MustSpecifyExtensionID }
|
|
63
|
+
return utils.patchToStringNested(makeConnectResponse())
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
utils.mockWithProxy(window.chrome.runtime, 'connect', function connect() {}, connectHandler)
|
|
67
|
+
function makeConnectResponse() {
|
|
68
|
+
const onSomething = () => ({
|
|
69
|
+
addListener: function addListener() {}, dispatch: function dispatch() {},
|
|
70
|
+
hasListener: function hasListener() {}, hasListeners: function hasListeners() { return false },
|
|
71
|
+
removeListener: function removeListener() {}
|
|
72
|
+
})
|
|
73
|
+
return {
|
|
74
|
+
name: '', sender: undefined,
|
|
75
|
+
disconnect: function disconnect() {},
|
|
76
|
+
onDisconnect: onSomething(), onMessage: onSomething(),
|
|
77
|
+
postMessage: function postMessage() {
|
|
78
|
+
if (!arguments.length) throw new TypeError('Insufficient number of arguments.')
|
|
79
|
+
throw new Error('Attempting to use a disconnected port object')
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const generate_magic_arrays = "\nfunction generateMagicArray(dataArray = [], proto = MimeTypeArray.prototype, itemProto = MimeType.prototype, itemMainProp = 'type') {\n const arr = []\n arr.__proto__ = proto\n for (const item of dataArray) {\n const obj = {}\n obj.__proto__ = itemProto\n for (const [key, value] of Object.entries(item)) {\n if (!key.startsWith('__')) { obj[key] = value }\n }\n Object.defineProperty(obj, itemMainProp, { configurable: true, enumerable: true, get: () => item[itemMainProp] })\n arr.push(obj)\n arr[item[itemMainProp]] = obj\n }\n const proxy = new Proxy(arr, {\n get(target, key) {\n if (key === 'length') { return target.length }\n if (key === Symbol.toStringTag) { return Object.getPrototypeOf(target)[Symbol.toStringTag] }\n if (key in target) { return target[key] }\n return undefined\n }\n })\n return proxy\n}\n";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate_magic_arrays = void 0;
|
|
4
|
+
exports.generate_magic_arrays = `
|
|
5
|
+
function generateMagicArray(dataArray = [], proto = MimeTypeArray.prototype, itemProto = MimeType.prototype, itemMainProp = 'type') {
|
|
6
|
+
const arr = []
|
|
7
|
+
arr.__proto__ = proto
|
|
8
|
+
for (const item of dataArray) {
|
|
9
|
+
const obj = {}
|
|
10
|
+
obj.__proto__ = itemProto
|
|
11
|
+
for (const [key, value] of Object.entries(item)) {
|
|
12
|
+
if (!key.startsWith('__')) { obj[key] = value }
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(obj, itemMainProp, { configurable: true, enumerable: true, get: () => item[itemMainProp] })
|
|
15
|
+
arr.push(obj)
|
|
16
|
+
arr[item[itemMainProp]] = obj
|
|
17
|
+
}
|
|
18
|
+
const proxy = new Proxy(arr, {
|
|
19
|
+
get(target, key) {
|
|
20
|
+
if (key === 'length') { return target.length }
|
|
21
|
+
if (key === Symbol.toStringTag) { return Object.getPrototypeOf(target)[Symbol.toStringTag] }
|
|
22
|
+
if (key in target) { return target[key] }
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
return proxy
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const iframe_contentWindow = "\ntry {\n const getContentWindowProxy = {\n apply: function(target, ctx, args) {\n const iframe = args[0]\n if (!iframe || iframe.nodeName !== 'IFRAME') { return utils.cache.Reflect.apply(target, ctx, args) }\n const win = utils.cache.Reflect.apply(target, ctx, args)\n win.Object = window.Object\n win.Reflect = window.Reflect\n return win\n }\n }\n Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', {\n get() {\n return new Proxy(HTMLIFrameElement.prototype.contentWindow, getContentWindowProxy)\n }\n })\n} catch (err) { /* noop */ }\n";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.iframe_contentWindow = void 0;
|
|
4
|
+
exports.iframe_contentWindow = `
|
|
5
|
+
try {
|
|
6
|
+
const getContentWindowProxy = {
|
|
7
|
+
apply: function(target, ctx, args) {
|
|
8
|
+
const iframe = args[0]
|
|
9
|
+
if (!iframe || iframe.nodeName !== 'IFRAME') { return utils.cache.Reflect.apply(target, ctx, args) }
|
|
10
|
+
const win = utils.cache.Reflect.apply(target, ctx, args)
|
|
11
|
+
win.Object = window.Object
|
|
12
|
+
win.Reflect = window.Reflect
|
|
13
|
+
return win
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(HTMLIFrameElement.prototype, 'contentWindow', {
|
|
17
|
+
get() {
|
|
18
|
+
return new Proxy(HTMLIFrameElement.prototype.contentWindow, getContentWindowProxy)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
} catch (err) { /* noop */ }
|
|
22
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const media_codecs = "\nconst makeCanPlayType = (supported, fn) => {\n utils.replaceWithProxy(HTMLMediaElement.prototype, 'canPlayType', {\n apply: function(target, ctx, args) {\n const type = (args || [])[0]\n const result = utils.cache.Reflect.apply(target, ctx, args)\n if (type === supported) { return 'probably' }\n return result\n }\n })\n}\nmakeCanPlayType('video/ogg; codecs=\"theora\"', fn => fn)\n";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.media_codecs = void 0;
|
|
4
|
+
exports.media_codecs = `
|
|
5
|
+
const makeCanPlayType = (supported, fn) => {
|
|
6
|
+
utils.replaceWithProxy(HTMLMediaElement.prototype, 'canPlayType', {
|
|
7
|
+
apply: function(target, ctx, args) {
|
|
8
|
+
const type = (args || [])[0]
|
|
9
|
+
const result = utils.cache.Reflect.apply(target, ctx, args)
|
|
10
|
+
if (type === supported) { return 'probably' }
|
|
11
|
+
return result
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
makeCanPlayType('video/ogg; codecs="theora"', fn => fn)
|
|
16
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_hardwareConcurrency = "\nutils.replaceProperty(Object.getPrototypeOf(navigator), 'hardwareConcurrency', { get: () => opts.navigator_hardware_concurrency || 4 })\n";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_hardwareConcurrency = void 0;
|
|
4
|
+
exports.navigator_hardwareConcurrency = `
|
|
5
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), 'hardwareConcurrency', { get: () => opts.navigator_hardware_concurrency || 4 })
|
|
6
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_languages = "\nutils.replaceProperty(Object.getPrototypeOf(navigator), 'languages', { get: () => opts.languages || ['en-US', 'en'] })\n";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_languages = void 0;
|
|
4
|
+
exports.navigator_languages = `
|
|
5
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), 'languages', { get: () => opts.languages || ['en-US', 'en'] })
|
|
6
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_permissions = "\nconst originalQuery = window.navigator.permissions.query\nwindow.navigator.permissions.__proto__.query = parameters =>\n parameters.name === 'notifications'\n ? Promise.resolve({ state: Notification.permission })\n : originalQuery(parameters)\nutils.patchToString(window.navigator.permissions.__proto__.query)\n";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_permissions = void 0;
|
|
4
|
+
exports.navigator_permissions = `
|
|
5
|
+
const originalQuery = window.navigator.permissions.query
|
|
6
|
+
window.navigator.permissions.__proto__.query = parameters =>
|
|
7
|
+
parameters.name === 'notifications'
|
|
8
|
+
? Promise.resolve({ state: Notification.permission })
|
|
9
|
+
: originalQuery(parameters)
|
|
10
|
+
utils.patchToString(window.navigator.permissions.__proto__.query)
|
|
11
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_platform = "\nif (opts.navigator_platform) {\n utils.replaceProperty(Object.getPrototypeOf(navigator), 'platform', { get: () => opts.navigator_platform })\n}\n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_platform = void 0;
|
|
4
|
+
exports.navigator_platform = `
|
|
5
|
+
if (opts.navigator_platform) {
|
|
6
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), 'platform', { get: () => opts.navigator_platform })
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_plugins_script = "\nconst data = {\n mimeTypes: [\n { type: 'application/pdf', suffixes: 'pdf', description: '', __pluginName: 'Chrome PDF Viewer' },\n { type: 'application/x-google-chrome-pdf', suffixes: 'pdf', description: 'Portable Document Format', __pluginName: 'Chrome PDF Plugin' },\n { type: 'application/x-nacl', suffixes: '', description: 'Native Client Executable', __pluginName: 'Native Client' },\n { type: 'application/x-pnacl', suffixes: '', description: 'Portable Native Client Executable', __pluginName: 'Native Client' }\n ],\n plugins: [\n { name: 'Chrome PDF Plugin', filename: 'internal-pdf-viewer', description: 'Portable Document Format', __mimeTypes: ['application/x-google-chrome-pdf'] },\n { name: 'Chrome PDF Viewer', filename: 'mhjfbmdgcfjbbpaeojofohoefgiehjai', description: '', __mimeTypes: ['application/pdf'] },\n { name: 'Native Client', filename: 'internal-nacl-plugin', description: '', __mimeTypes: ['application/x-nacl', 'application/x-pnacl'] }\n ]\n}\nconst hasPlugins = 'plugins' in navigator && navigator.plugins.length\nif (!hasPlugins) {\n const mimeTypes = generateMagicArray(data.mimeTypes, MimeTypeArray.prototype, MimeType.prototype, 'type')\n const plugins = generateMagicArray(data.plugins, PluginArray.prototype, Plugin.prototype, 'name')\n for (const pluginData of data.plugins) {\n pluginData.__mimeTypes.forEach((type, index) => {\n plugins[pluginData.name][index] = mimeTypes[type]\n plugins[type] = mimeTypes[type]\n Object.defineProperty(mimeTypes[type], 'enabledPlugin', {\n value: JSON.parse(JSON.stringify(plugins[pluginData.name])),\n writable: false, enumerable: false, configurable: false\n })\n })\n }\n const patchNavigator = (name, value) =>\n utils.replaceProperty(Object.getPrototypeOf(navigator), name, { get() { return value } })\n patchNavigator('mimeTypes', mimeTypes)\n patchNavigator('plugins', plugins)\n}\n";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_plugins_script = void 0;
|
|
4
|
+
exports.navigator_plugins_script = `
|
|
5
|
+
const data = {
|
|
6
|
+
mimeTypes: [
|
|
7
|
+
{ type: 'application/pdf', suffixes: 'pdf', description: '', __pluginName: 'Chrome PDF Viewer' },
|
|
8
|
+
{ type: 'application/x-google-chrome-pdf', suffixes: 'pdf', description: 'Portable Document Format', __pluginName: 'Chrome PDF Plugin' },
|
|
9
|
+
{ type: 'application/x-nacl', suffixes: '', description: 'Native Client Executable', __pluginName: 'Native Client' },
|
|
10
|
+
{ type: 'application/x-pnacl', suffixes: '', description: 'Portable Native Client Executable', __pluginName: 'Native Client' }
|
|
11
|
+
],
|
|
12
|
+
plugins: [
|
|
13
|
+
{ name: 'Chrome PDF Plugin', filename: 'internal-pdf-viewer', description: 'Portable Document Format', __mimeTypes: ['application/x-google-chrome-pdf'] },
|
|
14
|
+
{ name: 'Chrome PDF Viewer', filename: 'mhjfbmdgcfjbbpaeojofohoefgiehjai', description: '', __mimeTypes: ['application/pdf'] },
|
|
15
|
+
{ name: 'Native Client', filename: 'internal-nacl-plugin', description: '', __mimeTypes: ['application/x-nacl', 'application/x-pnacl'] }
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
const hasPlugins = 'plugins' in navigator && navigator.plugins.length
|
|
19
|
+
if (!hasPlugins) {
|
|
20
|
+
const mimeTypes = generateMagicArray(data.mimeTypes, MimeTypeArray.prototype, MimeType.prototype, 'type')
|
|
21
|
+
const plugins = generateMagicArray(data.plugins, PluginArray.prototype, Plugin.prototype, 'name')
|
|
22
|
+
for (const pluginData of data.plugins) {
|
|
23
|
+
pluginData.__mimeTypes.forEach((type, index) => {
|
|
24
|
+
plugins[pluginData.name][index] = mimeTypes[type]
|
|
25
|
+
plugins[type] = mimeTypes[type]
|
|
26
|
+
Object.defineProperty(mimeTypes[type], 'enabledPlugin', {
|
|
27
|
+
value: JSON.parse(JSON.stringify(plugins[pluginData.name])),
|
|
28
|
+
writable: false, enumerable: false, configurable: false
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
const patchNavigator = (name, value) =>
|
|
33
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), name, { get() { return value } })
|
|
34
|
+
patchNavigator('mimeTypes', mimeTypes)
|
|
35
|
+
patchNavigator('plugins', plugins)
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_userAgent_script = "\nif (opts.navigator_user_agent) {\n utils.replaceProperty(Object.getPrototypeOf(navigator), 'userAgent', { get: () => opts.navigator_user_agent })\n}\n";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_userAgent_script = void 0;
|
|
4
|
+
exports.navigator_userAgent_script = `
|
|
5
|
+
if (opts.navigator_user_agent) {
|
|
6
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), 'userAgent', { get: () => opts.navigator_user_agent })
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const navigator_vendor_script = "\nutils.replaceProperty(Object.getPrototypeOf(navigator), 'vendor', { get: () => opts.navigator_vendor || 'Google Inc.' })\n";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.navigator_vendor_script = void 0;
|
|
4
|
+
exports.navigator_vendor_script = `
|
|
5
|
+
utils.replaceProperty(Object.getPrototypeOf(navigator), 'vendor', { get: () => opts.navigator_vendor || 'Google Inc.' })
|
|
6
|
+
`;
|