首页龙虾技能列表 › Browser Session Manager — 技能工具

Browser Session Manager — 技能工具

v1.0.0

[自动翻译] Manage browser sessions for jimeng.jianying.com using Playwright by importing cookies/localStorage to automate video generation workflows with image u...

1· 800·5 当前·5 累计
by @flyingzl (石头)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/10
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
安全
medium confidence
The skill's code and instructions match its stated purpose (automating jimeng.jianying.com via Playwright) and do not show signs of covert exfiltration or unrelated privileges, but it handles sensitive session tokens and omits declared dependency/install metadata so review and caution are advised.
评估建议
This skill appears to do what it says (automate jimeng via Playwright) but it requires you to provide a browser session JSON containing cookies and localStorage values — those are equivalent to account credentials and can be used to act as you on the site. Before installing or running: 1) Review the included JS files yourself (they are present and readable); 2) Only use session exports from accounts you control or are willing to risk (prefer throwaway/test accounts); 3) Install Node.js, Playwrig...
详细分析 ▾
用途与能力
Name/description (Browser Session Manager for jimeng.jianying.com) matches the included SKILL.md and code: all files implement browser automation, cookie/localStorage injection, and UI interactions for the jimeng site. No unrelated services or credentials are requested.
指令范围
SKILL.md and scripts instruct the agent to read a session JSON (cookies/localStorage/sessionStorage), set them into a Playwright context, navigate and interact with the site, and optionally upload images/screenshots. This is within scope for session-based browser automation, but it necessarily requires handling sensitive authentication tokens (cookies/localStorage) which grant account access — users must understand this sensitivity. The instructions do not direct data to external endpoints beyond the target site and do not contain obvious exfiltration steps.
安装机制
There is no install spec in the registry metadata, but SKILL.md and the code require Node.js and Playwright (and mention ImageMagick's 'convert' for image preprocessing). The package metadata declares no required binaries; that mismatch (missing declared dependencies and no install instructions) is a usability/security concern because a user could run scripts without realizing external binaries will be invoked or downloaded (Playwright downloads browser binaries).
凭证需求
The skill does not request environment variables or other credentials in metadata. However, it consumes session JSON files that contain authentication cookies and tokens (e.g., sessionid, passport_csrf_token, odin_tt, ttwid). Access to those tokens is necessary for the stated purpose but is highly sensitive — providing them gives the script full authenticated access to the user's account on the target site.
持久化与权限
The skill does not request always:true, does not modify other skills or system-wide settings, and runs as a normal script. It writes screenshots/output to disk (paths like /tmp) which is expected. No evidence it persists credentials or elevates privileges beyond its own runtime.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/2/17

Initial release – automate browser Session management for Jimeng AI video generation: - Complete end-to-end guide for automating Jimeng AI video creation using Playwright. - Covers browser session management with imported cookies and localStorage. - Details image compression (to WebP) for file size compliance. - Provides working Node.js script for full browser automation: authentication, form filling, image upload, and workflow steps. - Documents troubleshooting for common cookie/session issues.

● 可疑

安装命令 点击复制

官方npx clawhub@latest install browser-session-manager
镜像加速npx clawhub@latest install browser-session-manager --registry https://cn.clawhub-mirror.com

技能文档

TL;DR: 本文记录如何通过 Playwright + 浏览器 Session 管理,实现即梦AI视频生成的全自动化。包含图片压缩、Cookie 注入、表单填写、视频提交等完整流程。

📋 背景

即梦AI (jimeng.jianying.com) 是字节跳动旗下的 AI 视频生成平台。官方提供了 Web 界面,但没有开放 API。当我们需要批量生成视频或集成到工作流时,就需要通过浏览器自动化来实现。

🎯 核心挑战

  • 登录状态保持: 需要正确处理 Cookies 和 LocalStorage
  • 文件上传: 需要压缩图片到合适大小(WebP 格式最佳)
  • 动态表单: 需要等待元素加载、处理弹窗
  • 提交检测: 需要检测页面跳转和生成状态

🛠️ 技术栈

  • Playwright: 浏览器自动化框架
  • ImageMagick: 图片压缩(convert 命令)
  • Node.js: 脚本运行环境

📁 目录结构

workspace/
├── screenshots/
│   └── YYYYMMDD_HHMMSS/     # 按时间戳组织的截图
│       ├── 01_initial.png
│       ├── 02_start_uploaded.png
│       └── ...
├── skills/
│   ├── browser-session-manager/  # Session 管理 Skill
│   └── web-form-automation/      # 表单自动化 Skill
└── session-data.json            # Cookie 数据文件

🚀 完整实现步骤

1. 准备阶段:图片压缩

即梦对上传图片有大小限制,必须先压缩:

# 转换为 WebP 格式,压缩到 30-50KB
convert start.png start.webp
convert end.png end.webp

# 验证大小 ls -lh .webp # -rw-r--r-- 1 node node 88K Feb 15 14:59 start.webp # -rw-r--r-- 1 node node 54K Feb 15 14:59 end.webp

⚠️ 重要: PNG 原图可能 4MB+,直接上传会失败。WebP 格式可压缩 99% 且画质损失极小。


2. Session 数据准备

从浏览器导出 Cookie 和 LocalStorage,保存为 JSON:

{
  "exportTime": "2026-02-15T14:55:58.374Z",
  "url": "https://jimeng.jianying.com/ai-tool/home?type=video",
  "hostname": "jimeng.jianying.com",
  "cookies": [
    {
      "name": "sessionid",
      "value": "xxx",
      "domain": ".jianying.com",
      "path": "/",
      "secure": false,
      "httpOnly": true,
      "sameSite": "unspecified"
    }
  ],
  "localStorage": {
    "dreamina__generator_video_modelKey": "\"dreamina_seedance_40_pro\"",
    "DREAMINA_THEME": "light"
  },
  "sessionStorage": {}
}

获取方法: 使用浏览器扩展(如 "Cookie-Editor")导出,或从 DevTools Application 面板复制。


3. 核心自动化脚本

const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');

async function generateVideo(sessionFile, startImage, endImage, prompt, screenshotDir) { // 读取 Session 数据 const sessionData = JSON.parse(fs.readFileSync(sessionFile, 'utf8')); // 启动浏览器 const browser = await chromium.launch({ headless: true, args: ['--no-sandbox'] }); const context = await browser.newContext(); const page = await context.newPage(); // ===== 关键步骤 1: 设置 Cookies ===== if (sessionData.cookies) { const cookiesByDomain = {}; for (const cookie of sessionData.cookies) { // 修复 sameSite 值 let sameSite = cookie.sameSite; if (sameSite === 'unspecified') sameSite = 'Lax'; if (sameSite === 'no_restriction') sameSite = 'None'; const fixedCookie = { ...cookie, sameSite }; const domain = cookie.domain || '.jianying.com'; if (!cookiesByDomain[domain]) cookiesByDomain[domain] = []; cookiesByDomain[domain].push(fixedCookie); } for (const [domain, cookies] of Object.entries(cookiesByDomain)) { try { await context.addCookies(cookies); } catch (e) { console.log(Cookie 设置失败: ${e.message}); } } } // ===== 关键步骤 2: 导航并注入 LocalStorage ===== await page.goto('https://jimeng.jianying.com/ai-tool/home?type=video', { waitUntil: 'domcontentloaded', timeout: 60000 }); await page.waitForTimeout(3000); // 注入 LocalStorage await page.evaluate((data) => { for (const [key, value] of Object.entries(data.localStorage || {})) { try { localStorage.setItem(key, value); } catch (e) {} } }, sessionData); // 刷新使存储生效 await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForTimeout(3000); // ===== 关键步骤 3: 处理登录弹窗 ===== try { const agreeBtn = await page.getByText('同意').first(); if (await agreeBtn.isVisible({ timeout: 3000 })) { await agreeBtn.click(); await page.waitForTimeout(2000); } } catch (e) { // 没有弹窗,继续 } // ===== 关键步骤 4: 上传首帧图片 ===== const startBtn = await page.getByText('首帧').first(); await startBtn.click(); await page.waitForTimeout(1500); const fileInput = await page.locator('input[type="file"]').first(); await fileInput.setInputFiles(startImage); await page.waitForTimeout(3000); // 等待上传完成 // ===== 关键步骤 5: 上传尾帧图片 ===== const endBtn = await page.getByText('尾帧').first(); await endBtn.click(); await page.waitForTimeout(1500); const fileInputs = await page.locator('input[type="file"]').all(); await fileInputs[fileInputs.length - 1].setInputFiles(endImage); await page.waitForTimeout(3000); // ===== 关键步骤 6: 选择模型 ===== const modelBtn = await page.getByText('Seedance 2.0 Fast').first(); await modelBtn.click(); await page.waitForTimeout(2000); // 选择 Seedance 2.0(非 Fast 版本) const seedance20 = await page.getByText('Seedance 2.0').nth(1); await seedance20.click(); await page.waitForTimeout(1500); // ===== 关键步骤 7: 设置时长为 15s ===== const durationBtn = await page.getByText('5s').first(); await durationBtn.click(); await page.waitForTimeout(1500); const fifteen = await page.getByText('15s').first(); await fifteen.click(); await page.waitForTimeout(1500); // ===== 关键步骤 8: 输入提示词 ===== const textarea = await page.locator('textarea').first(); await textarea.click(); // 使用 pressSequentially 模拟真实打字,触发输入事件 await textarea.pressSequentially(prompt, { delay: 30 }); await page.waitForTimeout(3000); // ===== 关键步骤 9: 提交生成 ===== const submit = await page.locator('button[class="submit"]').first(); await submit.click({ force: true }); // force: true 确保能点击 await page.waitForTimeout(2000); // ===== 关键步骤 10: 检测页面跳转 ===== await page.waitForTimeout(3000); const currentUrl = page.url(); if (currentUrl.includes('/generate')) { console.log('✅ 成功跳转到生成页面'); } // 等待 5 秒查看生成状态 await page.waitForTimeout(5000); await page.screenshot({ path: path.join(screenshotDir, 'final.png') }); await browser.close(); }


⚠️ 踩坑记录

1. Cookie sameSite 问题

错误: browserContext.addCookies: cookies[3].sameSite: expected one of (Strict|Lax|None)

解决: 导出时 `sameSite:

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务