npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chrome-extension-automator

v1.0.5

Published

Chrome扩展自动化测试框架 - 驱动无头浏览器加载扩展并记录网络流量

Readme

Chrome Extension Automator

Chrome 扩展自动化测试框架 —— 驱动无头浏览器加载扩展、执行自动化操作、记录所有网络流量域名。

架构

src/
├── index.js                  # 主入口 & Automator 编排器
├── browser/
│   └── launcher.js           # 浏览器启动(Puppeteer + 扩展加载)
├── network/
│   └── monitor.js            # 网络流量监控(CDP 全目标监听)
├── extension/
│   └── resolver.js           # 扩展页面解析(popup/options/SW/offscreen)
├── modules/
│   ├── base.js               # 自动化模块基类
│   └── example.js            # 示例模块
├── reporter/
│   └── domain-reporter.js    # 域名报告生成
└── example.js                # 完整使用示例

核心特性

  • 全目标网络监听:通过 CDP 协议附加到所有 Chrome 目标,包括:
    • 普通页面 (page)
    • Service Worker (service_worker)
    • Offscreen 文档 (other)
    • Background Page (background_page)
  • 模块化设计:继承 BaseModule 即可编写自动化操作模块
  • 扩展页面解析:自动发现扩展 ID,提供 popup/options/offscreen 等页面的访问
  • 域名报告:自动收集所有网络请求的目标域名,按来源类型分组

安装

npm install

快速开始

node src/example.js /path/to/your/extension

编程使用

import { Automator, BaseModule } from './src/index.js';

// 1. 编写自定义模块
class MyModule extends BaseModule {
  name = 'my-module';

  async run() {
    // this.browser      - Puppeteer Browser 实例
    // this.resolver      - ExtensionResolver 实例
    // this.extensionId   - 扩展 ID

    const popup = await this.resolver.openPopup(this.extensionId);
    await popup.click('#some-button');
    await popup.close();
  }
}

// 2. 配置并运行
const automator = new Automator({
  extension: { path: '/path/to/extension' },
  browser:   { headless: 'new' },
  reporter:  { format: 'text' },      // 'json' | 'text'
});

automator.use(MyModule);

const report = await automator.run();
// report.domains          - 域名列表
// report.domainsByTargetType - 按来源分组的域名

配置项

| 路径 | 说明 | 默认值 | |------|------|--------| | extension.path | 扩展目录路径(必填) | '' | | browser.headless | 无头模式 | 'new' | | browser.args | 额外 Chrome 参数 | [] | | browser.executablePath | Chrome 路径 | ''(使用内置) | | browser.timeout | 启动超时(ms) | 30000 | | network.targetTypes | 监控的目标类型 | ['page','service_worker','other','background_page'] | | reporter.format | 报告格式 | 'json' | | reporter.outputPath | 报告输出路径 | ''(控制台输出) |

自定义模块

继承 BaseModule,实现 run() 方法:

import { BaseModule } from './src/modules/base.js';

class ClickAllButtonsModule extends BaseModule {
  name = 'click-all-buttons';

  async setup() {
    // 可选:初始化逻辑
  }

  async run() {
    const popup = await this.resolver.openPopup(this.extensionId);
    const buttons = await popup.$$('button');
    for (const btn of buttons) {
      await btn.click();
      await new Promise(r => setTimeout(r, 500));
    }
    await popup.close();
  }

  async teardown() {
    // 可选:清理逻辑
  }
}

模块执行顺序与 automator.use() 的注册顺序一致。