← 返回 Skills 市场
zangzhicong

Bili Sunflower Publish

作者 zangzhicong · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
346
总下载
1
收藏
1
当前安装
2
版本数
在 OpenClaw 中安装
/install bili-sunflower-publish
功能描述
Publish HTML or Markdown content to Bilibili — supports both 专栏 (article) and 小站 (tribee) targets. Handles login check, title input, content injection via ed...
使用说明 (SKILL.md)

bili-sunflower-publish

Unified publish pipeline for Bilibili: HTML/Markdown file → editor → publish. Uses window.editor API directly — no system clipboard dependency.

Supports two targets:

  • 专栏 (Article): long-form articles on member.bilibili.com
  • 小站 (Tribee): community posts on bilibili.com/bubble

Prerequisites

  • Browser tool with openclaw profile (Playwright-managed browser)

Input

  • Content file path (article body) — supports .html and .md / .markdown files
  • Target type: article (专栏) or tribee (小站) — infer from user intent
  • Title (optional — see Phase 2)
  • For tribee: tribee name or ID (required)
  • For tribee: 分区 (category, optional — user can specify or choose during publish)

Phase 1: Navigate & Login Check

Article mode

Navigate to https://member.bilibili.com/york/read-editor and take a snapshot.

  • Logged in: editor loads with title textbox "请输入标题(建议30字以内)"
  • Not logged in: redirects to login page

Tribee mode

Publish URL: https://www.bilibili.com/bubble/publish?tribee_id={id}&tribee_name={name}

Both tribee_id and tribee_name are required for the publish URL. Resolve missing params:

User provides Resolution
id + name Direct → publish URL
id only Navigate to https://www.bilibili.com/bubble/home/{id}, extract tribee name from the page, then → publish URL
name only Search https://search.bilibili.com/all?keyword={name}, find the card linking to bilibili.com/bubble/home/{id}, extract {id}, then → publish URL

After navigating to the publish URL:

  • Logged in + member: editor loads with title and body area
  • Not logged in: redirects to login page
  • Not a member: may show join prompt — tell user to join the tribee first

If not logged in, stop and tell the user to log in manually in the openclaw browser profile, then retry.


Phase 2: Preprocess & Title Handling

Run the preprocess script matching the file type. The script handles H1 extraction, heading promotion, image inlining, and (for HTML) whitespace cleanup.

2a. For .html files

python3 {SKILL_DIR}/scripts/preprocess_html.py \x3Cinput.html> [output-dir]

Output (stdout, 3 lines):

title=\x3Cextracted title>
path=\x3Cprocessed html file path>
bytes=\x3Chtml byte size>

Parse title and path from the output. The processed HTML at path is ready for injection in Phase 3.

2b. For .md / .markdown files

python3 {SKILL_DIR}/scripts/preprocess_md.py \x3Cinput.md> [output-dir]

Output (stdout, 3 lines):

title=\x3Cextracted title>
path=\x3Cprocessed md file path>
bytes=\x3Cmd byte size>

Parse title and path from the output. The processed Markdown at path is ready for injection in Phase 3.

2c. Title validation

If the user provided a title explicitly, use it instead of the script-extracted one.

After resolving, validate:

  • Title > 50 characters: present 2-3 shortened alternatives, let user choose
  • Title looks meaningless (e.g. output, untitled, temp, or clearly unrelated to the content): read the first few hundred chars of body, generate 2-3 title suggestions, let user choose

Do NOT silently use a bad title. Wait for user selection before proceeding.

Enter the title: click the title textbox and type.


Phase 3: Insert Article Body

Both editors share the same rich-text editor component (window.editor).

Use the preprocessed content from Phase 2 and inject it into the editor.

IMPORTANT — JS string escaping:

Content (HTML or Markdown) often contains characters that break JS syntax (backticks, quotes, newlines, backslashes, etc.). You must use the method below to safely construct the JS code. Do NOT paste raw content directly into a JS variable assignment.

How to construct the evaluate JS code

Follow these steps exactly for both HTML and Markdown injection:

  1. Get the processed file path from Phase 2 output (path=...)
  2. Run the following command to produce a JSON-escaped string of the file content:
python3 -c "import json,sys; print(json.dumps(open(sys.argv[1]).read()))" \x3Cprocessed-file-path>

This outputs a double-quoted JSON string with all special characters escaped (newlines, quotes, backslashes, etc.), e.g. "line1\ line2\"quoted\"".

  1. Capture the stdout output as ESCAPED_JSON_STRING
  2. Build the full JS code by embedding ESCAPED_JSON_STRING into the template (see 3a-HTML / 3a-MD below). It already includes its own surrounding double quotes, so place it directly after JSON.parse( with no additional quotes.

3a-HTML. Processed HTML → ClipboardEvent dispatch

(function () {
  const html = JSON.parse(ESCAPED_JSON_STRING);
  const clipboardData = new DataTransfer();
  clipboardData.setData('text/html', html);
  clipboardData.setData('text/plain', '');

  const pasteEvent = new ClipboardEvent('paste', {
    bubbles: true,
    cancelable: true,
    clipboardData,
  });

  window.editor.view.dom.dispatchEvent(pasteEvent);
})();

Note: If the HTML content is large (>50KB), split it into chunks and paste sequentially.

3a-MD. Processed Markdown → editor importMarkdown command

(function () {
  const markdown = JSON.parse(ESCAPED_JSON_STRING);
  window.editor.commands.importMarkdown({
    content: markdown,
    replaceContent: true,
  });
})();

3b. Verify content

Evaluate JS to confirm content was inserted:

(function () {
  const e = window.editor.view.dom;
  return { chars: e.textContent.length, first80: e.textContent.substring(0, 80) };
})();

Expected: chars > 100 and first80 matches the article opening.


Phase 4: Publish

Article mode

Editor bottom has a "发布设置" panel (usually already visible) with defaults that work out of the box:

  • 可见范围: 所有人可见 (default)
  • 封面: auto-generated from body text (default)
  • 评论: enabled (default)

If the user has specific publishing preferences, adjust before publishing:

设置 操作 说明
可见范围 选 radio: "所有人可见" / "仅自己可见" 仅自己可见不支持分享和商业推广
自定义封面 勾选 checkbox → 上传图片 不设则自动抓正文开头文字
评论开关 勾选/取消 checkbox 关闭后无法评论
精选评论 勾选 checkbox 开启后需手动筛选评论才展示
定时发布 勾选 checkbox → 选择时间 范围: 当前+2h ~ 7天内,北京时间
创作声明-原创 勾选 checkbox 声明原创,禁止转载
创作声明-AI 勾选 checkbox 标识使用 AI 合成技术
话题 点击"添加话题"按钮 可选
文集 点击"选择文集"按钮 可选

Steps:

  1. Scroll down to confirm the "发布设置" panel is visible; if collapsed, click "发布设置" button to expand
  2. Apply any user-requested settings from the table above
  3. Click "发布" button (next to "保存为草稿", at the bottom right)
  4. If a confirmation dialog appears, confirm
  5. Verify publish succeeded (URL changes or success toast)

Tribee mode

Bottom bar appears after content is entered, with defaults that work out of the box:

  • 分区: 未选择 (some tribees may require)
  • 同步至动态: enabled (default)

If the user has specific preferences, adjust before publishing:

设置 操作 说明
分区 点击"选择分区"下拉 → 选择分区 部分小站可能必选
同步至动态 取消勾选 checkbox 默认开启,取消后不同步到动态

分区自动选择(Tribee only)

When the user did not specify a 分区:

  1. Click "选择分区" dropdown to reveal available options
  2. Read the list of 分区 names from the dropdown (snapshot)
  3. Based on the article title + first ~200 chars of body content, pick the most relevant 分区:
    • Match by keyword/topic similarity (e.g. tutorial content → "经验分享", questions → "提问求助")
    • If no option is a clear fit, pick the most general/catch-all option
    • If the tribee only has 1-2 generic options, just pick the best one without overthinking
  4. Click the chosen 分区
  5. Do not ask the user to confirm — just pick and proceed (they can always re-publish if wrong)

If the user did specify a 分区, use it directly (skip auto-selection).

Steps:

  1. Handle 分区 (user-specified or auto-selected per above)
  2. Apply any other user-requested settings
  3. Click "发布" button (blue, bottom right)
  4. Verify publish succeeded

Execution

Default: execute Phase 1 → 4 directly in the main session (supports user interaction for login/title).

Only delegate to subagent if the user explicitly requests it.

安全使用建议
This skill appears to do what it says: preprocess a local HTML/Markdown file (including inlining local images), open a Playwright-managed browser profile, inject the processed content into Bilibili's editor, and publish. Before installing or running it: 1) ensure you have python3 available (the SKILL.md and scripts call 'python3'); 2) confirm you have (or are willing to create) the required 'openclaw' Playwright browser profile—the skill will act using that browser profile and any logged-in Bilibili session it contains; 3) be aware the preprocessors will read any local image files referenced in your content and embed them as base64 (so they will be read from disk); 4) test with a draft or a throwaway account first (the skill will click publish if instructed); 5) if you want extra assurance, review the two included scripts (they are short and only perform local file parsing and base64 inlining) and run them manually to inspect outputs before letting the agent run them. If the skill instead attempted network uploads to unknown endpoints, required unrelated credentials, or included external downloads, the assessment would change to suspicious or worse.
功能分析
Type: OpenClaw Skill Name: bili-sunflower-publish Version: 1.0.1 The skill bundle is a legitimate tool for publishing HTML or Markdown content to Bilibili. It includes Python scripts (preprocess_html.py and preprocess_md.py) for local image inlining and heading adjustments, and uses safe JSON-escaping techniques to inject content into the browser's editor API, effectively preventing script injection. No evidence of data exfiltration, unauthorized execution, or malicious prompt injection was found.
能力评估
Purpose & Capability
The skill claims to publish to Bilibili and the instruction flow, pages visited, and included preprocess scripts match that purpose. However, the SKILL.md expects a Playwright-managed 'openclaw' browser profile and calls python3 for preprocessing, but the registry metadata did not declare required binaries (python3) or the browser tool requirement—this is an omission rather than a functional mismatch.
Instruction Scope
Instructions are explicit and narrowly scoped to: navigate to Bilibili editor pages, check login status, preprocess a local HTML/MD file, inject content into the page via the editor API/paste events, and click publish. The skill reads local files (the user-supplied content and referenced local images) and scrapes Bilibili pages to resolve tribee IDs—these behaviors are necessary for the stated functionality.
Install Mechanism
This is instruction-only with small included Python helper scripts. There is no install spec, no external downloads, and no archive extraction—so nothing is automatically written or fetched during install beyond running local scripts at runtime.
Credentials
The skill requests no environment variables or credentials. It does, however, require executing python3 and running inside an OpenClaw/Playwright browser profile that may contain your Bilibili session cookies—the skill will act using that session to publish content. It also reads local files and inlines local images (base64), which is expected but worth noting.
Persistence & Privilege
always is false and the skill is user-invocable. It does not request persistent system-wide privileges or modify other skills. Autonomous invocation is allowed (platform default) but not combined with other high-risk flags.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install bili-sunflower-publish
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /bili-sunflower-publish 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
**Major update: Adds Markdown support, removes system clipboard dependency, and injects content via the Bilibili editor API.** - Now supports publishing both HTML and Markdown (.md/.markdown) files. - Content is preprocessed via Python scripts for HTML and Markdown, with improved title extraction and file handling. - System clipboard and macOS dependency removed; uses direct JS injection into the Bilibili editor (`window.editor` API). - Robust JS string escaping ensures safe content insertion, even for large or complex articles. - Scripts for HTML/MD preprocessing added; obsolete clipboard script removed. - Documentation (README, SKILL.md) updated to reflect new workflow and requirements.
v1.0.0
Initial release: Publish HTML content to Bilibili专栏 (article) or小站 (tribee) targets on macOS. - Supports login check, title handling (with meaningful-title validation), HTML paste via clipboard, and publish workflow. - Allows publishing to B站专栏/小站 with user-specified or inferred targets and article metadata. - Automatically resolves tribee IDs or names if only one is given by the user. - Provides fallback clipboard injection if standard paste fails. - Supports user preferences for publishing settings (visibility, category, etc.).
元数据
Slug bili-sunflower-publish
版本 1.0.1
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 2
常见问题

Bili Sunflower Publish 是什么?

Publish HTML or Markdown content to Bilibili — supports both 专栏 (article) and 小站 (tribee) targets. Handles login check, title input, content injection via ed... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 346 次。

如何安装 Bili Sunflower Publish?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install bili-sunflower-publish」即可一键安装,无需额外配置。

Bili Sunflower Publish 是免费的吗?

是的,Bili Sunflower Publish 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Bili Sunflower Publish 支持哪些平台?

Bili Sunflower Publish 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Bili Sunflower Publish?

由 zangzhicong(@zangzhicong)开发并维护,当前版本 v1.0.1。

💬 留言讨论