@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.js CHANGED
@@ -1824,8 +1824,8 @@ var Interception = {
1824
1824
  * @param {import('playwright').Page} page - Playwright Page 对象
1825
1825
  * @param {Object} [options] - 配置选项
1826
1826
  * @param {string[]} [options.directDomains] - [已过时] 需要直连的域名列表,请改用 directConfig.domains
1827
- * @param {string[]} [options.directExtensions] - 需要直连的扩展名(如 .js/.css)
1828
1827
  * @param {Object} [options.directConfig] - 直连配置(参考 blockingConfig),支持 domains/directAllXxx 系列开关
1828
+ * @param {boolean|Function} [options.enable] - 是否启用拦截处理(false 时始终 continue)
1829
1829
  * @param {Object} [options.blockingConfig] - 资源屏蔽配置
1830
1830
  * @param {boolean} [options.fallbackToProxy] - 直连失败时是否回退到代理(默认 true)
1831
1831
  * @returns {Promise<void>}
@@ -1833,8 +1833,8 @@ var Interception = {
1833
1833
  async setup(page, options = {}) {
1834
1834
  const {
1835
1835
  directDomains = [],
1836
- directExtensions = [],
1837
1836
  directConfig = {},
1837
+ enable = true,
1838
1838
  blockingConfig = {},
1839
1839
  fallbackToProxy = true
1840
1840
  } = options;
@@ -1850,7 +1850,7 @@ var Interception = {
1850
1850
  const hasDirectDomains = normalizedDirectDomains.length > 0;
1851
1851
  const normalizedDirectExtensions = Array.from(
1852
1852
  new Set(
1853
- [...directExtensions, ...configuredDirectExtensions].map((ext) => String(ext || "").toLowerCase().trim()).filter(Boolean).map((ext) => ext.startsWith(".") ? ext : `.${ext}`)
1853
+ configuredDirectExtensions.map((ext) => String(ext || "").toLowerCase().trim()).filter(Boolean).map((ext) => ext.startsWith(".") ? ext : `.${ext}`)
1854
1854
  )
1855
1855
  );
1856
1856
  const hasDirectExtensions = normalizedDirectExtensions.length > 0;
@@ -1874,6 +1874,12 @@ var Interception = {
1874
1874
  const url = request.url();
1875
1875
  const urlLower = url.toLowerCase();
1876
1876
  const urlPath = urlLower.split("?")[0];
1877
+ const interceptionEnabled = typeof enable === "function" ? Boolean(enable()) : Boolean(enable);
1878
+ if (!interceptionEnabled) {
1879
+ await safeContinue(route);
1880
+ handled = true;
1881
+ return;
1882
+ }
1877
1883
  const isSilent = DirectConfig.silentExtensions.some((ext) => urlPath.endsWith(ext));
1878
1884
  const shouldBlock = blockedExtensions.some((ext) => urlPath.endsWith(ext));
1879
1885
  if (shouldBlock) {