@tocha688/browser 0.0.1 → 1.0.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/CHANGELOG.md +12 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -4
- package/package.json +2 -2
- package/src/actions/auto/types.ts +63 -63
- package/src/const/browser.ts +214 -214
- package/src/core/launcher.ts +45 -45
- package/src/human/mouse.ts +308 -308
- package/src/index.ts +12 -12
- package/src/network/cache.ts +129 -129
- package/src/network/resource.ts +61 -61
- package/src/providers/ads_tool.ts +38 -38
- package/src/providers/adspower.ts +17 -7
- package/src/providers/base.ts +14 -2
- package/src/providers/local.ts +12 -3
- package/src/providers/ok.ts +8 -2
- package/src/types/index.ts +3 -0
package/src/providers/ok.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { faker } from "@faker-js/faker";
|
|
2
2
|
import type { BrowserResult, BrowserStartOptions } from "../types";
|
|
3
|
-
import { startProxyServer, type ProxyServerResult } from "@tocha688/utils";
|
|
3
|
+
import { getIpInfo, startProxyServer, type ProxyServerResult } from "@tocha688/utils";
|
|
4
4
|
import { launchBrowserBase } from "./base";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
@@ -13,6 +13,12 @@ export async function OKBrowserStartMain(opts: BrowserStartOptions): Promise<Bro
|
|
|
13
13
|
proxy = await startProxyServer(opts.proxy);
|
|
14
14
|
console.log(`Started proxy server on port ${proxy.port}`);
|
|
15
15
|
}
|
|
16
|
+
let ipinfo: any = proxy?.ipinfo;
|
|
17
|
+
if (ipinfo) {
|
|
18
|
+
//获取本地IP
|
|
19
|
+
ipinfo = await getIpInfo(ipinfo.proxy);
|
|
20
|
+
}
|
|
21
|
+
|
|
16
22
|
|
|
17
23
|
const fingerprintPath = path.join(userDataDir, "fingerprint.config");
|
|
18
24
|
let fingerprint: string;
|
|
@@ -71,7 +77,7 @@ export async function OKBrowserStartMain(opts: BrowserStartOptions): Promise<Bro
|
|
|
71
77
|
"--ignores=tls",
|
|
72
78
|
"--enable-logging",
|
|
73
79
|
// "--proxy-server=http://127.0.0.1:" + proxy.port,
|
|
74
|
-
"--timezone=" + (
|
|
80
|
+
"--timezone=" + (ipinfo?.timezone ?? "America/Los_Angeles"),
|
|
75
81
|
"--lang=en-US",
|
|
76
82
|
// "--headless", // Handled by base
|
|
77
83
|
];
|
package/src/types/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ProxyFormatInfo } from "@tocha688/utils/ip";
|
|
2
2
|
import * as cl from "chrome-launcher"
|
|
3
|
+
import type { Page } from "patchright-core";
|
|
3
4
|
import * as ProxyChain from "proxy-chain";
|
|
4
5
|
|
|
5
6
|
// 使用方式
|
|
@@ -14,6 +15,8 @@ export type BrowserResult = {
|
|
|
14
15
|
port: number,
|
|
15
16
|
browser: cl.LaunchedChrome,
|
|
16
17
|
close: Function,
|
|
18
|
+
wsUrl: string,
|
|
19
|
+
mainPage:()=>Promise<Page>
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
export type StartBrowserFn = (opts: BrowserStartOptions) => Promise<BrowserResult>;
|