@skrillex1224/playwright-toolkit 2.1.135 → 2.1.136
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/dist/index.cjs +9 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +9 -3
- package/dist/index.js.map +2 -2
- package/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1851,8 +1851,8 @@ var Interception = {
|
|
|
1851
1851
|
* @param {import('playwright').Page} page - Playwright Page 对象
|
|
1852
1852
|
* @param {Object} [options] - 配置选项
|
|
1853
1853
|
* @param {string[]} [options.directDomains] - [已过时] 需要直连的域名列表,请改用 directConfig.domains
|
|
1854
|
-
* @param {string[]} [options.directExtensions] - 需要直连的扩展名(如 .js/.css)
|
|
1855
1854
|
* @param {Object} [options.directConfig] - 直连配置(参考 blockingConfig),支持 domains/directAllXxx 系列开关
|
|
1855
|
+
* @param {boolean|Function} [options.enable] - 是否启用拦截处理(false 时始终 continue)
|
|
1856
1856
|
* @param {Object} [options.blockingConfig] - 资源屏蔽配置
|
|
1857
1857
|
* @param {boolean} [options.fallbackToProxy] - 直连失败时是否回退到代理(默认 true)
|
|
1858
1858
|
* @returns {Promise<void>}
|
|
@@ -1860,8 +1860,8 @@ var Interception = {
|
|
|
1860
1860
|
async setup(page, options = {}) {
|
|
1861
1861
|
const {
|
|
1862
1862
|
directDomains = [],
|
|
1863
|
-
directExtensions = [],
|
|
1864
1863
|
directConfig = {},
|
|
1864
|
+
enable = true,
|
|
1865
1865
|
blockingConfig = {},
|
|
1866
1866
|
fallbackToProxy = true
|
|
1867
1867
|
} = options;
|
|
@@ -1877,7 +1877,7 @@ var Interception = {
|
|
|
1877
1877
|
const hasDirectDomains = normalizedDirectDomains.length > 0;
|
|
1878
1878
|
const normalizedDirectExtensions = Array.from(
|
|
1879
1879
|
new Set(
|
|
1880
|
-
|
|
1880
|
+
configuredDirectExtensions.map((ext) => String(ext || "").toLowerCase().trim()).filter(Boolean).map((ext) => ext.startsWith(".") ? ext : `.${ext}`)
|
|
1881
1881
|
)
|
|
1882
1882
|
);
|
|
1883
1883
|
const hasDirectExtensions = normalizedDirectExtensions.length > 0;
|
|
@@ -1901,6 +1901,12 @@ var Interception = {
|
|
|
1901
1901
|
const url = request.url();
|
|
1902
1902
|
const urlLower = url.toLowerCase();
|
|
1903
1903
|
const urlPath = urlLower.split("?")[0];
|
|
1904
|
+
const interceptionEnabled = typeof enable === "function" ? Boolean(enable()) : Boolean(enable);
|
|
1905
|
+
if (!interceptionEnabled) {
|
|
1906
|
+
await safeContinue(route);
|
|
1907
|
+
handled = true;
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1904
1910
|
const isSilent = DirectConfig.silentExtensions.some((ext) => urlPath.endsWith(ext));
|
|
1905
1911
|
const shouldBlock = blockedExtensions.some((ext) => urlPath.endsWith(ext));
|
|
1906
1912
|
if (shouldBlock) {
|