@skrillex1224/playwright-toolkit 3.0.42 → 3.0.44
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/README.md +1 -1
- package/dist/browser.js +72 -33
- package/dist/browser.js.map +2 -2
- package/dist/index.cjs +77 -38
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +77 -38
- package/dist/index.js.map +2 -2
- package/index.d.ts +10 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -226,7 +226,7 @@ const cookies = Utils.parseCookies('key=value; key2=value2', '.example.com');
|
|
|
226
226
|
await page.context().addCookies(cookies);
|
|
227
227
|
|
|
228
228
|
// 全页面滚动截图 (自动检测所有滚动元素,强制展开后截图,默认会执行 watermarkify)
|
|
229
|
-
// 默认会将返回的 base64 压缩到
|
|
229
|
+
// 默认会将返回的 base64 压缩到 500KiB 以内,避免 Apify/Crawlee dataset 单条 item 超限
|
|
230
230
|
const base64Image = await Share.captureScreen(page);
|
|
231
231
|
|
|
232
232
|
// 截图只使用当前页面运行时 viewport;移动端请通过 ActorInfo.device 切换,不再通过截图参数覆盖
|
package/dist/browser.js
CHANGED
|
@@ -2602,6 +2602,12 @@ var createActorInfo = (info) => {
|
|
|
2602
2602
|
if (!raw) return "/";
|
|
2603
2603
|
return raw.startsWith("/") ? raw : `/${raw}`;
|
|
2604
2604
|
};
|
|
2605
|
+
const normalizePaths = (value) => {
|
|
2606
|
+
const raw = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2607
|
+
return Object.fromEntries(
|
|
2608
|
+
Object.entries(raw).map(([key, item]) => [String(key || "").trim(), normalizePath(item)]).filter(([key]) => Boolean(key))
|
|
2609
|
+
);
|
|
2610
|
+
};
|
|
2605
2611
|
const normalizeShare = (value) => {
|
|
2606
2612
|
const raw = value && typeof value === "object" ? value : {};
|
|
2607
2613
|
const modeRaw = String(raw.mode || "dom").trim().toLowerCase();
|
|
@@ -2668,6 +2674,7 @@ var createActorInfo = (info) => {
|
|
|
2668
2674
|
const protocol = info.protocol || "https";
|
|
2669
2675
|
const domain = normalizeDomain(info.domain);
|
|
2670
2676
|
const path = normalizePath(info.path);
|
|
2677
|
+
const paths = Object.freeze(normalizePaths(info.paths));
|
|
2671
2678
|
const share = normalizeShare(info.share);
|
|
2672
2679
|
const device = normalizeDevice(info.device);
|
|
2673
2680
|
return {
|
|
@@ -2677,6 +2684,9 @@ var createActorInfo = (info) => {
|
|
|
2677
2684
|
path,
|
|
2678
2685
|
share,
|
|
2679
2686
|
device,
|
|
2687
|
+
get paths() {
|
|
2688
|
+
return paths;
|
|
2689
|
+
},
|
|
2680
2690
|
get icon() {
|
|
2681
2691
|
if (info.icon) return info.icon;
|
|
2682
2692
|
return buildIcon(this);
|
|
@@ -2714,6 +2724,11 @@ var ActorInfo = {
|
|
|
2714
2724
|
name: "\u7075\u5149",
|
|
2715
2725
|
domain: "www.lingguang.com",
|
|
2716
2726
|
path: "/",
|
|
2727
|
+
paths: {
|
|
2728
|
+
settings: "/settings/personal",
|
|
2729
|
+
personalization: "/settings/personal",
|
|
2730
|
+
memory: "/settings/personal"
|
|
2731
|
+
},
|
|
2717
2732
|
share: {
|
|
2718
2733
|
mode: "response",
|
|
2719
2734
|
prefix: "https://www.lingguang.com/share/",
|
|
@@ -2728,6 +2743,11 @@ var ActorInfo = {
|
|
|
2728
2743
|
name: "\u8C46\u5305",
|
|
2729
2744
|
domain: "www.doubao.com",
|
|
2730
2745
|
path: "/",
|
|
2746
|
+
paths: {
|
|
2747
|
+
settings: "/settings/memory",
|
|
2748
|
+
privacy: "/settings/memory",
|
|
2749
|
+
memory: "/settings/memory"
|
|
2750
|
+
},
|
|
2731
2751
|
device: Device.Desktop,
|
|
2732
2752
|
share: {
|
|
2733
2753
|
mode: "response",
|
|
@@ -2744,6 +2764,10 @@ var ActorInfo = {
|
|
|
2744
2764
|
name: "DeepSeek",
|
|
2745
2765
|
domain: "chat.deepseek.com",
|
|
2746
2766
|
path: "/",
|
|
2767
|
+
paths: {
|
|
2768
|
+
settings: "/",
|
|
2769
|
+
personalization: "/"
|
|
2770
|
+
},
|
|
2747
2771
|
share: {
|
|
2748
2772
|
mode: "response",
|
|
2749
2773
|
prefix: "https://chat.deepseek.com/share/",
|
|
@@ -2798,6 +2822,11 @@ var ActorInfo = {
|
|
|
2798
2822
|
name: "\u5143\u5B9D",
|
|
2799
2823
|
domain: "yuanbao.tencent.com",
|
|
2800
2824
|
path: "/chat/",
|
|
2825
|
+
paths: {
|
|
2826
|
+
settings: "/setting",
|
|
2827
|
+
personalization: "/setting",
|
|
2828
|
+
memory: "/setting"
|
|
2829
|
+
},
|
|
2801
2830
|
device: Device.Mobile,
|
|
2802
2831
|
share: {
|
|
2803
2832
|
mode: "response",
|
|
@@ -2813,6 +2842,10 @@ var ActorInfo = {
|
|
|
2813
2842
|
name: "Kimi",
|
|
2814
2843
|
domain: "www.kimi.com",
|
|
2815
2844
|
path: "/",
|
|
2845
|
+
paths: {
|
|
2846
|
+
settings: "/settings?toOpenItem=memory",
|
|
2847
|
+
memory: "/settings?toOpenItem=memory"
|
|
2848
|
+
},
|
|
2816
2849
|
device: Device.Mobile,
|
|
2817
2850
|
share: {
|
|
2818
2851
|
mode: "response",
|
|
@@ -2829,6 +2862,10 @@ var ActorInfo = {
|
|
|
2829
2862
|
name: "\u901A\u4E49\u5343\u95EE",
|
|
2830
2863
|
domain: "www.qianwen.com",
|
|
2831
2864
|
path: "/chat",
|
|
2865
|
+
paths: {
|
|
2866
|
+
settings: "/chat",
|
|
2867
|
+
memory: "/chat"
|
|
2868
|
+
},
|
|
2832
2869
|
device: Device.Mobile,
|
|
2833
2870
|
share: {
|
|
2834
2871
|
mode: "response",
|
|
@@ -2845,6 +2882,10 @@ var ActorInfo = {
|
|
|
2845
2882
|
name: "\u7EB3\u7C73",
|
|
2846
2883
|
domain: "www.n.cn",
|
|
2847
2884
|
path: "/",
|
|
2885
|
+
paths: {
|
|
2886
|
+
settings: "/",
|
|
2887
|
+
memory: "/"
|
|
2888
|
+
},
|
|
2848
2889
|
share: {
|
|
2849
2890
|
mode: "response",
|
|
2850
2891
|
prefix: "https://www.n.cn/share/mcp?id=",
|
|
@@ -2970,6 +3011,7 @@ var PageRuntimeStateKey = "__playwright_toolkit_runtime_state__";
|
|
|
2970
3011
|
var BROWSER_PROFILE_SCHEMA_VERSION = 1;
|
|
2971
3012
|
var SUPPORTED_CLOAK_FINGERPRINT_PLATFORMS = /* @__PURE__ */ new Set(["linux", "macos", "windows"]);
|
|
2972
3013
|
var logger = createInternalLogger("RuntimeEnv");
|
|
3014
|
+
var MAX_RUNTIME_STORAGE_VALUE_CHARS = 256 * 1024;
|
|
2973
3015
|
var rememberedRuntimeState = null;
|
|
2974
3016
|
var isPlainObject = (value) => value && typeof value === "object" && !Array.isArray(value);
|
|
2975
3017
|
var normalizeKnownDevice = (value) => {
|
|
@@ -3013,25 +3055,23 @@ var tryParseJSON = (value) => {
|
|
|
3013
3055
|
return null;
|
|
3014
3056
|
}
|
|
3015
3057
|
};
|
|
3016
|
-
var
|
|
3058
|
+
var normalizeStorageString = (value) => String(value != null ? value : "").replace(/\u0000/g, "").trim();
|
|
3059
|
+
var normalizeStorageEntries = (value) => {
|
|
3017
3060
|
const source = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3018
3061
|
return Object.entries(source).reduce((acc, [key, item]) => {
|
|
3019
|
-
const safeKey =
|
|
3020
|
-
const safeValue =
|
|
3062
|
+
const safeKey = normalizeStorageString(key);
|
|
3063
|
+
const safeValue = normalizeStorageString(item);
|
|
3021
3064
|
if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
|
|
3065
|
+
if (safeValue.length > MAX_RUNTIME_STORAGE_VALUE_CHARS) return acc;
|
|
3022
3066
|
acc[safeKey] = safeValue;
|
|
3023
3067
|
return acc;
|
|
3024
3068
|
}, {});
|
|
3025
3069
|
};
|
|
3070
|
+
var normalizeLocalStorage = (value) => {
|
|
3071
|
+
return normalizeStorageEntries(value);
|
|
3072
|
+
};
|
|
3026
3073
|
var normalizeSessionStorage = (value) => {
|
|
3027
|
-
|
|
3028
|
-
return Object.entries(source).reduce((acc, [key, item]) => {
|
|
3029
|
-
const safeKey = String(key || "").trim();
|
|
3030
|
-
const safeValue = String(item != null ? item : "").trim();
|
|
3031
|
-
if (!safeKey || !safeValue || safeValue === "<nil>") return acc;
|
|
3032
|
-
acc[safeKey] = safeValue;
|
|
3033
|
-
return acc;
|
|
3034
|
-
}, {});
|
|
3074
|
+
return normalizeStorageEntries(value);
|
|
3035
3075
|
};
|
|
3036
3076
|
var normalizeCookieSameSite = (value) => {
|
|
3037
3077
|
const raw = String(value || "").trim().toLowerCase();
|
|
@@ -3224,29 +3264,28 @@ var captureRawSnapshotFromPage = async (page) => {
|
|
|
3224
3264
|
return "";
|
|
3225
3265
|
}
|
|
3226
3266
|
}) : [];
|
|
3227
|
-
const snapshot = await page.evaluate(() => {
|
|
3228
|
-
const
|
|
3229
|
-
const
|
|
3267
|
+
const snapshot = await page.evaluate((maxStorageValueChars) => {
|
|
3268
|
+
const normalizeStorageStringInPage = (value) => String(value != null ? value : "").replace(/\u0000/g, "").trim();
|
|
3269
|
+
const readStorageArea = (storage) => {
|
|
3270
|
+
const result = {};
|
|
3271
|
+
try {
|
|
3272
|
+
for (let i = 0; i < storage.length; i += 1) {
|
|
3273
|
+
const rawKey = storage.key(i);
|
|
3274
|
+
const key = normalizeStorageStringInPage(rawKey);
|
|
3275
|
+
if (!key) continue;
|
|
3276
|
+
const value = normalizeStorageStringInPage(storage.getItem(rawKey));
|
|
3277
|
+
if (!value || value === "<nil>") continue;
|
|
3278
|
+
if (value.length > maxStorageValueChars) continue;
|
|
3279
|
+
result[key] = value;
|
|
3280
|
+
}
|
|
3281
|
+
} catch {
|
|
3282
|
+
}
|
|
3283
|
+
return result;
|
|
3284
|
+
};
|
|
3285
|
+
const localStorage = readStorageArea(window.localStorage);
|
|
3286
|
+
const sessionStorage = readStorageArea(window.sessionStorage);
|
|
3230
3287
|
const resourceUrls = [];
|
|
3231
3288
|
const frameUrls2 = [];
|
|
3232
|
-
try {
|
|
3233
|
-
for (let i = 0; i < window.localStorage.length; i += 1) {
|
|
3234
|
-
const key = window.localStorage.key(i);
|
|
3235
|
-
if (!key) continue;
|
|
3236
|
-
const value = window.localStorage.getItem(key);
|
|
3237
|
-
if (value !== null) localStorage[key] = value;
|
|
3238
|
-
}
|
|
3239
|
-
} catch {
|
|
3240
|
-
}
|
|
3241
|
-
try {
|
|
3242
|
-
for (let i = 0; i < window.sessionStorage.length; i += 1) {
|
|
3243
|
-
const key = window.sessionStorage.key(i);
|
|
3244
|
-
if (!key) continue;
|
|
3245
|
-
const value = window.sessionStorage.getItem(key);
|
|
3246
|
-
if (value !== null) sessionStorage[key] = value;
|
|
3247
|
-
}
|
|
3248
|
-
} catch {
|
|
3249
|
-
}
|
|
3250
3289
|
try {
|
|
3251
3290
|
const perfEntries = performance.getEntriesByType("resource") || [];
|
|
3252
3291
|
perfEntries.forEach((entry) => {
|
|
@@ -3293,7 +3332,7 @@ var captureRawSnapshotFromPage = async (page) => {
|
|
|
3293
3332
|
}
|
|
3294
3333
|
}
|
|
3295
3334
|
};
|
|
3296
|
-
});
|
|
3335
|
+
}, MAX_RUNTIME_STORAGE_VALUE_CHARS);
|
|
3297
3336
|
return normalizeRawSnapshot({
|
|
3298
3337
|
...snapshot,
|
|
3299
3338
|
frame_urls: [...frameUrls, ...(snapshot == null ? void 0 : snapshot.frame_urls) || []]
|