Load Claude-chan onto any page把 Claude-chan 加载到任意网页
Full version = sprites (default). Every method below loads the real sprite art: 21 hand-drawn poses and 15 motions, fetched from the base URL (or embedded in the inline build). Simplified version = a code-drawn stand-in that appears only if the sprites cannot be loaded, or when you ask for it with simplified:true. It has fewer expressions/poses and no real art.
完整版 = 精灵图(默认)。下面每种方式都会加载真正的精灵图:21 个手绘姿势和 15 个动作,从基础地址获取(内嵌版则直接内置)。简化版 = 代码绘制的替身,只有在精灵图无法加载时才会出现,或当你用 simplified:true 主动要求时。它的表情和姿势更少,也没有真正的美术。
- The simplified version lacks: the 21 hand-drawn poses (idea, giggle, cheer, typing, explain, away, ...), the real anime art (it is a plain code-drawn figure), and the sprite cross-fades. It only tilts, blinks, moves brows, mouth and arms.简化版缺少:21 个手绘姿势(灵感、咯咯笑、欢呼、打字、讲解、离开等)、真正的动漫美术(只是简单的代码绘制人物)以及精灵图的淡入淡出。它只会倾斜、眨眼、动眉毛、嘴和手臂。
- How to tell: after loading,
claudeChan.rendereris"sprites"(full) or"simplified",claudeChan.isSimplifiedis true/false, andclaudeChan.help()prints it. If the sprites fail, the console showsclaude-chan: sprites could not be loaded from …; showing the SIMPLIFIED code-drawn version.如何判断:加载后claudeChan.renderer为"sprites"(完整)或"simplified"(简化),claudeChan.isSimplified为 true/false,claudeChan.help()也会打印。精灵图加载失败时,控制台会显示claude-chan: sprites could not be loaded from …; showing the SIMPLIFIED code-drawn version。 - Live2D (optional): set
window.claudeChanConfig = { renderer: "live2d", model: "https://…/claude-chan.model3.json" }before loading. Only then are the Cubism Core (official Live2D CDN) and the Live2D runtime fetched; if anything fails she shows the sprites. See docs/LIVE2D.md.Live2D(可选):加载前设置window.claudeChanConfig = { renderer: "live2d", model: "https://…/claude-chan.model3.json" }。只有这样才会获取 Cubism Core(Live2D 官方 CDN)和 Live2D 运行库;任何部分失败都会显示精灵图。见 docs/LIVE2D.md。
Pick one way below: a console line, a bookmark, or a userscript. Every snippet already uses the base URL from the field, so it is ready to copy.
下面任选一种方式:控制台一行代码、书签或用户脚本。每段代码都已经填好了上方输入框里的基础地址,可以直接复制。
https://kmaj1st.github.io/claude-chan/: GitHub Pages (default when this page is opened as a file).https://kmaj1st.github.io/claude-chan/:GitHub Pages(以本地文件打开本页时的默认值)。http://127.0.0.1:5179/: local copy, afternpm run serve:loader.http://127.0.0.1:5179/:本地副本,先运行npm run serve:loader。https://cdn.jsdelivr.net/gh/Kmaj1st/claude-chan@main/: jsDelivr, works only once the GitHub repository is public.https://cdn.jsdelivr.net/gh/Kmaj1st/claude-chan@main/:jsDelivr,仅在 GitHub 仓库公开后可用。
1. Console (script hot-load)1. 控制台(脚本热加载)
Open the page where you want her, press F12 (or Ctrl+Shift+J / Cmd+Option+J), open the Console tab, paste this line and press Enter:
打开要放她的网页,按 F12(或 Ctrl+Shift+J / Cmd+Option+J),切到 Console(控制台) 标签,粘贴下面这行并回车:
document.head.append(Object.assign(document.createElement('script'),{src:'https://kmaj1st.github.io/claude-chan/hotload/loader.js'}))Or as a module import (also works where document.head is missing):
或者用模块导入(在没有 document.head 的页面也能用):
import('https://kmaj1st.github.io/claude-chan/hotload/loader.js')- Chrome and Edge block the first paste into the console: type
allow pasting, press Enter, then paste again. Firefox asks the same.Chrome 和 Edge 会拦截第一次粘贴:先输入allow pasting并回车,再粘贴一次。Firefox 也会这样提示。 - What you should see: Claude-chan in the bottom-left corner within a second, and
window.claudeChanin the console.应看到:一秒内 Claude-chan 出现在左下角,控制台里可以访问window.claudeChan。 - Running it twice does nothing: there is never more than one mascot.重复运行不会有副作用:页面上永远只有一个吉祥物。
- Remove her with
claudeChan.unload(). Reloading the page removes her too.用claudeChan.unload()移除她;刷新页面也会移除。
2. Bookmarklet2. 书签
Drag this button to your bookmarks bar (show it with Ctrl+Shift+B). Click the bookmark on any page to add Claude-chan; click it again to remove her.
把这个按钮拖到书签栏(Ctrl+Shift+B 显示书签栏)。在任意网页点击该书签即可加入 Claude-chan,再点一次移除。
If dragging does not work: create a new bookmark and paste this code into its URL field.
如果拖不动:新建一个书签,把下面的代码粘贴到网址栏。
javascript:(()=>{const c=window.claudeChan;if(window.__claudeChanLoader&&c&&c.unload){c.unload();return}const s=document.createElement("script");s.src="https://kmaj1st.github.io/claude-chan/hotload/loader.js";s.onerror=()=>alert("claude-chan: could not load "+s.src+" (blocked by this site's Content-Security-Policy? See docs/HOT-LOAD.md)");(document.head||document.documentElement).appendChild(s)})()3. Userscript (every page, automatically)3. 用户脚本(每个网页自动加载)
Install Tampermonkey or Violentmonkey, then open one of these links; the manager offers to install it:
先安装 Tampermonkey 或 Violentmonkey 扩展,再打开下面的链接,扩展会弹出安装页面:
- Install claude-chan.user.js安装 claude-chan.user.js (plain loader, about 50 KB; FULL version, fetches the sprites from the base URL)(普通加载器,约 50 KB;完整版,从基础地址获取精灵图)
- Install claude-chan.inline.user.js安装 claude-chan.inline.user.js (inline, strict-CSP sites; FULL version, all 21 poses and 15 motions embedded, about 2.3 MB)(内嵌版,适用于严格 CSP 的网站;完整版,内嵌全部 21 个姿势和 15 个动作,约 2.3 MB)
- It runs on every page (
@match *://*/*). To limit it, edit the@matchlines in the manager, for examplehttps://example.com/*.默认在所有网页运行(@match *://*/*)。要限制范围,在扩展里编辑@match行,例如https://example.com/*。 - The userscripts load sprites from
https://kmaj1st.github.io/claude-chan/.用户脚本从https://kmaj1st.github.io/claude-chan/加载图像。
4. Sites with a strict Content-Security-Policy4. 内容安全策略(CSP)严格的网站
Some sites (for example GitHub) only allow their own scripts. Symptom: nothing appears, the console shows Refused to load the script … because it violates the following Content Security Policy directive, and the bookmarklet shows an alert.
有些网站(例如 GitHub)只允许自己的脚本。现象:什么都没出现,控制台显示 Refused to load the script … Content Security Policy,书签会弹出提示。
- Use the inline userscript (
claude-chan.inline.user.js): the manager injects it, and the sprites are embedded.改用内嵌版用户脚本(claude-chan.inline.user.js):由扩展注入,图像已内嵌。 - If even
data:images are blocked, the sprites cannot load and she shows the SIMPLIFIED code-drawn version instead (fewer poses, no real art; see the top of this page).如果连data:图像也被禁止,精灵图无法加载,她会显示简化版(代码绘制,姿势更少,没有真正的美术;见本页顶部)。 - The console line and the bookmarklet add a script tag, which CSP blocks. Pasting the contents of
claude-chan.inline.jsinto the console works on most CSP sites.控制台代码和书签会添加 script 标签,会被 CSP 拦截。把claude-chan.inline.js的文件内容粘贴到控制台,在大多数 CSP 网站上可用。
5. Options and console commands5. 选项与控制台命令
Set options before loading, as window.claudeChanConfig or as data-* attributes on the script tag:
在加载前设置选项:用 window.claudeChanConfig,或在 script 标签上写 data-* 属性:
window.claudeChanConfig = { position: 'bottom-right', dock: 'free', size: 180, zIndex: 2147483000, simplified: false };
document.head.append(Object.assign(document.createElement('script'),{src:'https://kmaj1st.github.io/claude-chan/hotload/loader.js'}))<script src="https://kmaj1st.github.io/claude-chan/hotload/loader.js" data-position="bottom-right" data-size="180"></script>position: bottom-left (default), bottom-right, top-left, top-right.dock: free (drag anywhere) or fixed-default.size: height in px.zIndex: stacking order.position:bottom-left(默认)、bottom-right、top-left、top-right。dock:free(可随意拖动)或 fixed-default。size:高度(像素)。zIndex:层级。simplified: false (default, full sprite version) or true to deliberately show the SIMPLIFIED code-drawn stand-in.sprites: URL of the sprite folder (default:base+assets/chars/).simplified:false(默认,完整精灵版)或 true(主动显示简化的代码绘制替身)。sprites:精灵图文件夹地址(默认base+assets/chars/)。- Attributes:
data-position,data-dock,data-size,data-z-index,data-base,data-sprites,data-frames,data-simplified.属性名:data-position、data-dock、data-size、data-z-index、data-base、data-sprites、data-frames、data-simplified。
Console commands once she is loaded:
加载后可在控制台使用:
claudeChan.help() // list of commands
claudeChan.hide() // hide for this page load
claudeChan.hide({ persist: true }) // stay hidden after reloads (until show())
claudeChan.show() // show again
claudeChan.toggle() // hide/show, returns true when visible
claudeChan.setPosition(0.8, 0.9) // fractions 0..1 of the window (numbers > 1 are px)
claudeChan.resetPosition() // back to the home corner
claudeChan.unload() // remove her completely
claudeChan.unload({ forget: true }) // also forget the stored position
claudeChan.renderer // "sprites" (full version), "live2d" (Cubism model) or "simplified"6. Troubleshooting6. 故障排查
- Nothing appears. Look at the status line at the top of this page: it must say OK for your base URL. In DevTools open the Network tab and check that
loader.jsreturns 200.什么都没出现。先看本页顶部的状态行,必须显示 OK。在开发者工具的 Network(网络) 标签里确认loader.js返回 200。 - Wrong base URL (404): the base must be the folder that contains
hotload/, ending with/.基础地址错误(404):基础地址必须是包含hotload/的目录,并以/结尾。 - CSP error in the console: see section 4.控制台出现 CSP 错误:见第 4 节。
- Ad or script blockers can block
loader.js; allow the base host for that site.广告或脚本拦截扩展可能拦截loader.js;为该网站放行基础地址的域名。 - Inside an iframe she does not mount unless
frames: trueis set; run the line in the top page.在 iframe 里默认不加载,除非设置frames: true;请在顶层页面运行。 - Mixed content: an
https://page may not load scripts fromhttp://hosts, excepthttp://127.0.0.1(localhost counts as secure).混合内容:https://页面不能从http://地址加载脚本,http://127.0.0.1除外(本机地址视为安全)。 - Old art or old behaviour after an update: GitHub Pages lets browsers cache files for 10 minutes. Wait, or hard-refresh (Ctrl+F5 / Cmd+Shift+R). A base you set in
window.claudeChanConfig.basealways wins over the one baked into the userscript.更新后仍是旧图像或旧行为:GitHub Pages 允许浏览器缓存文件 10 分钟。请稍等,或强制刷新(Ctrl+F5 / Cmd+Shift+R)。在window.claudeChanConfig.base中自行设置的基础地址总是优先于用户脚本内置的地址。 - 404 from jsDelivr: jsDelivr only serves public repositories. Use the GitHub Pages base until the repository is public.jsDelivr 返回 404:jsDelivr 只提供公开仓库的文件。仓库公开前请使用 GitHub Pages 地址。
More: docs/HOT-LOAD.md.
更多内容:docs/HOT-LOAD.md。