swarm-cursors README

项目的 README,来自 github.com/DhvanilPatel/swarm-cursors。合并为一个 markdown 文件:README.md。

Swarm Rebuild

A Chrome extension that wipes any web page to a blank canvas and lets a swarm of multiplayer cursors build it back, live: crosshair-drawn boxes, typed text, pen-tool lines, ruler guides and ⌥-drag duplicates, until the page looks just like it did before.

Swarm Rebuild rebuilding a page

Install from the Chrome Web Store · Full demo video (36s) · Demo with sound (60s)

Credit

This is a tribute to Swarm by Joel Califa (@califa, source), a website that builds itself as you scroll.

The motion design is his: the cursor set, the swarm and flocking physics, the build choreography (rects, typing, guides, duplicates), the rulers and the overall look. Large parts of the animation engine here are adapted directly from his site. What this project adds is the part that points it at any page: snapshotting a live DOM into a blueprint the swarm can rebuild, plus the extension around it.

Go look at the original. It's better than this.

Install

Add it from the Chrome Web Store, then pin it (puzzle icon → pin).

The store version can lag behind this repo while an update is in review. To run the latest code, load it unpacked:

  1. Clone or download this repo.
  2. Open chrome://extensions and turn on Developer mode (top right).
  3. Click Load unpacked and choose the swarm-rebuild/ folder.
  4. Pin it (puzzle icon → pin).

Use

There's a self-contained test page in demo/index.html (an inner-scrolling app shell with floats, forms, cards and media). Opening local files needs Allow access to file URLs enabled for the extension.

How it works

  1. Snapshot. swarm.js walks the live DOM, including open shadow roots, and turns it into a blueprint:
    • boxes with fills, borders, radii, shadows, gradients, masks and backdrop blur → rects
    • text blocks → text layers, cloned with their computed styles (fonts, links, inline code, icons, ::before/::after)
    • single-side borders and <hr> → pen-tool lines
    • <img>, <svg>, <video>, <canvas>, iframes → media. WebGL canvases, playing video and cross-origin iframes are cropped from a screenshot taken at click time while only those elements are visible.
    • repeated siblings (nav links, cards, list rows, logos) → one master plus duplicates
    • shared left edges and baselines → ruler guides that text snaps to
  2. Blank. A full-viewport layer, isolated from the page's CSS in a shadow root, covers the page with its own background color. A quick hidden scroll pass first triggers lazy images and reveal-on-scroll content.
  3. Rebuild. Each cursor runs a small generator script per task. Tasks unlock top-down as you scroll, children wait for their parent box, and duplicates wait for their master:
    • rect / media: crosshair drag with a live W × H badge and a gray placeholder, then the real fill fades in (images sweep top to bottom)
    • text: drag a text box, type with an I-beam and a blinking caret; big headings start at 18px and step up
    • lines: pen tool, anchor points, rubber band to the cursor
    • guides: Figma-style rulers slide in, a red guide is dragged out, and text snaps onto it
    • duplicates: select the master, ⌥-drag a copy with red spacing measurements, then retype its text, swap its image or restyle it
    • swarm physics: orbiting, alignment and mouse-avoiding flocking for the intro and the finale
  4. Sound. Synthesized live with the Web Audio API (no audio files), mostly clicky, a little musical:
    • typing is a mechanical keyboard (a sharp click over a short thock, deeper on spaces), and every mouse press is a press-and-release click
    • guides snap with a crisp click, and growing headings tick up in pitch
    • boxes, images and duplicates add a sparse, quiet glass-piano note from the E major pentatonic, on an eighth-note grid: big sections play low, small things high, pitch rises left to right, and every sound is panned to its cursor
    • an airy swell as the page dissolves, a short arpeggio as the swarm fans out, a soft E major chord when the page is done, and a falling sweep for Go live

Files

Path What it is
swarm-rebuild/manifest.json Manifest V3; permissions are activeTab, scripting and storage. Site access is optional and only requested if you turn on automatic play
swarm-rebuild/background.js Toolbar click → media-only screenshot → inject swarm.js (or toggle off)
swarm-rebuild/swarm.js Snapshot, renderer and swarm engine (one dependency-free content script)
swarm-rebuild/options.html, options.js Automatic play setting
swarm-rebuild/autoplay.js Tiny loader registered only on the sites where automatic play is on
demo/index.html Edge-case test page
store/ Chrome Web Store listing copy, screenshots and promo tile
scripts/package.sh Builds the zip to upload to the Web Store

Limits

Publishing

./scripts/package.sh writes dist/swarm-rebuild-<version>.zip for the Chrome Web Store Developer Dashboard. Listing text, permission justifications and assets are in store/, and the privacy policy is PRIVACY.md.

License

None yet. The original Swarm site is published without a license and this project adapts parts of it, so please don't reuse this code without checking with Joel Califa as well.

swarm-cursors (DhvanilPatel/swarm-cursors)

正在搜索数据库…

这是什么?这是一个 Chrome 扩展,它会先把任意网页清空成空白画布,再用一群多人光标实时将其重建,直到页面重新呈现原来的样子。
它和原版 Swarm 网站有什么不同?Joel Califa 的 Swarm 是一个随着滚动自行搭建页面的网站。本项目则把同样的动效设计应用到任意页面上:先把实时 DOM 拍成蓝图,再由蜂群按蓝图重建。
我要怎么让它运行起来?它暂时还没有上架 Chrome 应用商店,所以请先克隆仓库,打开 chrome://extensions,开启开发者模式,点击“加载已解压的扩展程序”,然后选择 swarm-rebuild/ 文件夹。
我需要先准备什么?只需要安装 Chrome 并开启开发者模式即可。引擎是一个无依赖的单一内容脚本,README 中没有提到任何构建步骤。
哪些情况下无法使用?Chrome 会在 chrome:// 页面、Chrome 应用商店和 PDF 查看器上禁止扩展运行。这是视觉层面的重建,因此动画会被冻结,Web 组件会变成普通的带样式元素,超长页面最多只能生成约 4,000 个图层。
它在浏览器中会请求哪些权限?清单中只声明了 activeTab 和 scripting 权限,因此它只作用于你激活的那个页面。README 指向一个 PRIVACY.md 文件,但没有在那里概述其内容。
我可以复用这些代码吗?目前还没有许可证。原版 Swarm 网站未附带许可证,作者要求你在复用这些代码前先与 Joel Califa 确认。
「Go live」和「Replay」是做什么的?「Go live」会在蜂群完成重建后,将其淡出,切换回可点击的真实页面。「Replay」会重新构建页面。「Tour」会以蜂群能跟上的速度自动滚动,方便录制屏幕视频。
它是如何捕获页面的?swarm.js 会遍历实时 DOM(包括开放的 Shadow Root),把方框、文字、边框和媒体转换成蓝图。WebGL 画布、视频和跨域 iframe 则会根据点击时拍下的截图进行裁剪。
它的声音设计听起来是什么样的?输入时的声音像机械键盘,参考线吸附时会发出“咔哒”一声,方框、图片和复制元素会以 E 大调五声音阶发出轻柔的玻璃钢琴音,并根据各自光标的位置调整声像。
没有真实网站,我能试用吗?可以,demo/index.html 是一个独立的测试页面,包含内部滚动的应用外壳、浮动元素、表单、卡片和媒体。若要打开本地文件,需要在扩展设置中开启“允许访问文件网址”。
大小
20 MB
星标
3.5K
更新
提交Nov 11
时长
1个月
提交 · 90 天