Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions external_plugins/web-task-extension/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "web-task-extension",
"version": "0.1.0",
"description": "Turn a browser chore you repeat into a Chrome / Edge extension. Describe it; it becomes steps (open, click, fill, wait, extract rows with fields across pages, download CSV / JSON or linked files) with user settings, and a Manifest V3 extension with a Run button popup, an options page, minimal permissions explained in plain words, and a store-ready zip. The manifest and code are validated (references, icons, permissions vs. steps, MV3 CSP, scripts, locales). No login automation.",
"description_i18n": {
"en": "Turn a browser chore you repeat into a Chrome / Edge extension. Describe it; it becomes steps (open, click, fill, wait, extract rows with fields across pages, download CSV / JSON or linked files) with user settings, and a Manifest V3 extension with a Run button popup, an options page, minimal permissions explained in plain words, and a store-ready zip. The manifest and code are validated (references, icons, permissions vs. steps, MV3 CSP, scripts, locales). No login automation.",
"zh-CN": "把你在浏览器里反复做的操作变成 Chrome / Edge 扩展。描述一下流程,就会整理成步骤(打开、点击、填写、等待、跨页提取带字段的数据、下载 CSV / JSON 或链接文件)和设置项,并生成 Manifest V3 扩展:带“运行任务”按钮的弹窗、设置页、最小权限及通俗的权限说明,以及可上传商店的 zip。自动校验 manifest 和代码(引用文件、图标、权限与步骤是否一致、MV3 CSP、脚本、多语言)。不做自动登录。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"chrome extension",
"browser extension",
"manifest v3",
"automation",
"web scraping",
"rpa",
"edge",
"浏览器扩展",
"自动化",
"网页操作",
"数据提取",
"插件"
],
"skills": "skills",
"mcpServers": {
"web-task-extension": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "网页操作转浏览器扩展",
"en-US": "Web Task Extension"
},
"icon": "puzzle",
"server": "web-task-extension",
"resourceUri": "ui://web-task-extension/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/web-task-extension/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
63 changes: 63 additions & 0 deletions external_plugins/web-task-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Web Task Extension

Turn a chore you repeat in the browser into a **Chrome / Edge extension** you run with one click. Describe the routine; the agent writes it as steps and this plugin generates, validates and zips a **Manifest V3** extension with **minimal, explained permissions**.

## What it does

- **Steps**:
- `open` a URL, `click` (by selector, optionally by text), `fill` text / `<select>` / checkboxes (optionally submit), `wait` for an element (or until it disappears, or a delay).
- `extract` one record per element with named fields (`".price"`, `"a@href"`, `"@data-id"`), following a **next-page** link up to N pages.
- `download` an extracted dataset as **CSV** (UTF-8 with BOM, safe against spreadsheet formulas) or **JSON**, or the files that links point to.
- **Settings** the user fills in on the options page (text, number, date, select), used as `{{key}}`; built-ins `{{today}}`, `{{now}}`. Optional steps, per-step timeouts and notes.
- **Generates** `extensions/<name>/`:
- Popup: a **Run task** button, live step progress, a results preview and CSV / JSON re-download.
- Options page: settings, the step list and the permission table.
- Service worker that runs the steps in a tab with `chrome.scripting`. Generated icons, English and Chinese UI (`_locales`), `PERMISSIONS.md` and `README.md` with load instructions.
- A store-ready zip: `extensions/<name>-<version>.zip`.
- **Minimal permissions**:
- Always `storage` and `scripting`.
- `downloads` only with a download step.
- Host access only to the sites the steps open, plus any extra sites you list. With no Open step it uses `activeTab` instead and has no host access.
- Never `tabs`, `<all_urls>`, cookies, history, webRequest or always-on content scripts. Each permission is explained in plain English and Chinese.
- **Validation**:
- Manifest: V3; name / description / version rules; all referenced files exist; icons are PNGs of the declared sizes.
- Permissions: known, minimal, and exactly the ones the steps need; host patterns valid and covering every Open URL.
- Code: no inline or remote scripts, inline handlers or `javascript:` URLs (MV3 CSP); every script parses; no `eval`.
- Locales are complete, and the task is consistent: placeholders are defined, downloads follow an extract, and placeholders can't change the site.
- Use `ext_check` to re-run it after hand edits.

## Usage

Ask the agent in ZCode Desktop:

- "Every morning I search our supplier portal for brake parts and copy the in-stock ones into a spreadsheet; make that an extension"
- "Make an extension that saves this table as CSV"
- "Add a step that also downloads the spec sheets"

Then on `chrome://extensions`: turn on **Developer mode**, click **Load unpacked**, choose the folder, pin the extension and press **Run task**. In the panel you can see the steps, permissions, a popup preview and the checks. **Edit steps** (JSON) regenerates the extension and bumps its version.

## Tools

| Tool | Purpose |
|---|---|
| `ext_new` | Create an extension from steps and settings: generate, validate, zip |
| `ext_update` | Change steps / settings / sites / name, regenerate, bump the version |
| `ext_check` | Re-validate the folder as it is on disk, re-zip when clean |
| `ext_list` | List generated extensions |

## Scope (v0.1)

- Chrome / Edge (Manifest V3, Chrome 110+). Firefox is not targeted.
- Logging in is not automated: sign in yourself before running. Don't put passwords in settings (the plugin warns).
- Sites that block automation, CAPTCHAs, iframes from other sites and shadow DOM selectors aren't handled.
- Publishing to the Chrome Web Store is up to you (the zip is ready).
- The extension runs when you press Run; scheduling is not included.

## Privacy, network and files

- The plugin runs locally with no network access and no API keys. It writes `extensions/<name>/`, the zip and `.web-task-extension/extensions.json`.
- The generated extension sends nothing anywhere. It only drives the listed sites when you press Run and keeps settings and results in the browser.

## License

MIT. Uses [fflate](https://github.com/101arrowz/fflate) (MIT) for the zip.
63 changes: 63 additions & 0 deletions external_plugins/web-task-extension/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 网页操作转浏览器扩展

把你在浏览器里反复做的事变成一个 **Chrome / Edge 扩展**,点一下就自动跑完。描述一下流程,Agent 把它写成步骤,本插件生成 **Manifest V3** 扩展,**只申请必要权限并逐项说明用途**,自动校验后打包。

## 功能

- **步骤**:
- `open` 打开网址;`click` 点击(按选择器,可再按文字筛选);`fill` 填写文本 / 下拉框 / 复选框(可提交表单);`wait` 等待元素出现、消失或固定时长。
- `extract` 每个元素提取一条记录,字段可写成 `".price"`、`"a@href"`、`"@data-id"`,可沿“下一页”最多翻 N 页。
- `download` 把提取的数据存成 **CSV**(UTF-8 带 BOM,防表格公式注入)或 **JSON**,或下载链接指向的文件。
- **设置项**由用户在设置页填写(文本、数字、日期、下拉),步骤里写 `{{key}}` 引用;另有内置的 `{{today}}`、`{{now}}`。步骤可设为可选,可单独设超时和备注。
- **生成** `extensions/<名称>/`:
- 弹窗:**运行任务**按钮、实时步骤进度、结果预览、重新下载 CSV / JSON。
- 设置页:设置项、步骤列表、权限说明表。
- 用 `chrome.scripting` 在标签页里执行步骤的 Service Worker;自动生成的图标;中英文界面(`_locales`);`PERMISSIONS.md`;附加载说明的 `README.md`。
- 可直接上传商店的 zip:`extensions/<名称>-<版本>.zip`。
- **最小权限**:
- 固定只有 `storage`、`scripting`。
- 有下载步骤才加 `downloads`。
- 网站权限只包含步骤打开的网站和你额外列出的网站;没有“打开”步骤时改用 `activeTab`,不申请任何网站权限。
- 从不申请 `tabs`、`<all_urls>`、cookies、history、webRequest,也没有常驻内容脚本。每项权限都用中英文通俗说明。
- **校验**:
- Manifest:V3;名称、描述、版本号规则;引用的文件都存在;图标是对应尺寸的 PNG。
- 权限:都是已知权限、最小化,且与步骤完全对应;网站匹配模式合法,并覆盖每个打开的网址。
- 代码:没有内联或远程脚本、内联事件、`javascript:` 链接(MV3 CSP);所有脚本语法正确;不用 `eval`。
- 多语言文案齐全;任务前后一致:占位符都有定义,下载在提取之后,占位符不能改变网站。
- 手动改过文件后用 `ext_check` 重新校验。

## 使用

在 ZCode Desktop 里对 Agent 说:

- “我每天早上在供应商门户搜刹车配件,把有货的抄进表格,帮我做成扩展”
- “做一个把这个页面表格存成 CSV 的扩展”
- “再加一步,把规格单也下载下来”

然后打开 `chrome://extensions`,开启**开发者模式**,点**加载已解压的扩展程序**并选择文件夹,固定图标后点**运行任务**。面板里能看到步骤、权限、弹窗预览和校验结果;点**编辑步骤**(JSON)可以修改,修改后会重新生成并升级版本号。

## 工具

| 工具 | 用途 |
|---|---|
| `ext_new` | 按步骤和设置项新建扩展:生成、校验、打包 |
| `ext_update` | 修改步骤 / 设置 / 网站 / 名称,重新生成并升级版本号 |
| `ext_check` | 按磁盘上的现状重新校验,没问题就重新打包 |
| `ext_list` | 列出已生成的扩展 |

## 范围(v0.1)

- 支持 Chrome / Edge(Manifest V3,Chrome 110+),暂不支持 Firefox。
- 不自动登录:请先自己登录网站再运行。不要把密码写进设置项(插件会提醒)。
- 不处理:屏蔽自动化的网站、验证码、跨站 iframe、Shadow DOM 选择器。
- 发布到 Chrome 应用商店由你自己决定(zip 已备好)。
- 需要点“运行任务”才执行,不含定时运行。

## 隐私、网络与文件

- 插件本身在本地运行,不联网,不需要 API Key。会写入 `extensions/<名称>/`、zip 和 `.web-task-extension/extensions.json`。
- 生成的扩展不向任何地方发送数据。只在你点“运行任务”时操作列出的网站,设置和结果保存在浏览器里。

## 许可

MIT。打包 zip 使用 [fflate](https://github.com/101arrowz/fflate)(MIT)。
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: web-task-extension
description: 把用户在浏览器里重复做的操作(打开网页、点击、填写、等待、提取数据、下载)生成 Chrome / Edge Manifest V3 扩展:弹窗运行按钮、设置页、最小权限及说明、校验、zip。用户提到“做成浏览器扩展 / Chrome 插件 / 自动帮我在网页上… / 每天在某网站上重复操作”时使用。
---

# 网页操作转浏览器扩展

1. 先问清楚流程:从哪个网址开始,依次点什么、填什么,要提取哪些字段,是否翻页,最后存成什么文件。每次运行可能变化的值(搜索词、分类、日期)做成设置项,步骤里用 `{{key}}` 引用。不要把密码或验证码写进任务:登录不在范围内,请用户运行前自己登录。
2. 选择器尽量稳定:优先用 id、name、data-* 和语义化的 class;如果用户能提供页面 HTML 或网址,先读一下再写选择器。表格数据用 `extract`:`selector` 写成每行一个元素(如 `table tr.item`),`fields` 写成 `{ "列名": "td.price" }`,取属性写 `"a@href"`;需要翻页时加 `next`(下一页按钮)和 `maxPages`。可能出现也可能不出现的元素(如 Cookie 横幅),点击步骤加 `optional: true`。
3. 调用 `ext_new({name, description, steps, settings?, sites?})`。如果步骤会通过点击跳转到其他网站,把这些网站加进 `sites`。工具返回 `bad_task` 时,按提示修正后再调用。
4. 报告结果:扩展所在文件夹和 zip、申请了哪些权限及原因、校验结果(有“!”提醒的说明一下),以及加载方法:`chrome://extensions` → 开发者模式 → 加载已解压的扩展程序 → 选择文件夹 → 固定图标 → 运行任务。
5. 用户要修改时用 `ext_update({out, steps?, settings?, sites?, name?})`,会自动升级版本号,提醒用户在扩展页点刷新。用户手动改过文件后用 `ext_check({out})` 重新校验。
6. 不在范围内的需求要直接说明:自动登录、验证码、定时运行、发布到商店(zip 已备好,由用户自己决定是否发布)。
50 changes: 50 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,56 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "web-task-extension",
"componentTypes": [
"ui"
],
"source": "./external_plugins/web-task-extension",
"displayName": "Web Task Extension",
"displayName_i18n": {
"en": "Web Task Extension",
"zh-CN": "网页操作转浏览器扩展"
},
"description": "Turn a browser chore you repeat into a Chrome / Edge extension. Describe it; it becomes steps (open, click, fill, wait, extract rows with fields across pages, download CSV / JSON or linked files) with user settings, and a Manifest V3 extension with a Run button popup, an options page, minimal permissions explained in plain words, and a store-ready zip. The manifest and code are validated (references, icons, permissions vs. steps, MV3 CSP, scripts, locales). No login automation.",
"description_i18n": {
"en": "Turn a browser chore you repeat into a Chrome / Edge extension. Describe it; it becomes steps (open, click, fill, wait, extract rows with fields across pages, download CSV / JSON or linked files) with user settings, and a Manifest V3 extension with a Run button popup, an options page, minimal permissions explained in plain words, and a store-ready zip. The manifest and code are validated (references, icons, permissions vs. steps, MV3 CSP, scripts, locales). No login automation.",
"zh-CN": "把你在浏览器里反复做的操作变成 Chrome / Edge 扩展。描述一下流程,就会整理成步骤(打开、点击、填写、等待、跨页提取带字段的数据、下载 CSV / JSON 或链接文件)和设置项,并生成 Manifest V3 扩展:带“运行任务”按钮的弹窗、设置页、最小权限及通俗的权限说明,以及可上传商店的 zip。自动校验 manifest 和代码(引用文件、图标、权限与步骤是否一致、MV3 CSP、脚本、多语言)。不做自动登录。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "productivity",
"keywords": [
"chrome extension",
"browser extension",
"manifest v3",
"automation",
"web scraping",
"rpa",
"edge",
"浏览器扩展",
"自动化",
"网页操作",
"数据提取",
"插件"
],
"examplePrompts": [
"Every morning I search our supplier portal for brake parts and copy the in-stock ones into a spreadsheet; make that an extension",
"Make an extension that saves this table as CSV",
"Add a step that also downloads the spec sheets"
],
"examplePrompts_i18n": {
"zh-CN": [
"我每天早上在供应商门户搜刹车配件,把有货的抄进表格,帮我做成扩展",
"做一个把这个页面表格存成 CSV 的扩展",
"再加一步,把规格单也下载下来"
]
}
}
]
}
Loading