GitPedia

Shuffle article

Shuffle text in the DOM while preserving visual rendering for lightweight copy protection.

From Innei·Updated April 16, 2026·View on GitHub·

Shuffle text in the DOM while preserving visual rendering — a lightweight anti-copy protection technique. The project is written primarily in TypeScript, first published in 2021. Key topics include: anti-copy, content-protection, copy-protection, dom, dom-manipulation.

Shuffle Article

article-shuffle on npm
react-article-shuffle on npm
Live Demo

Shuffle text in the DOM while preserving visual rendering — a lightweight anti-copy protection technique.

在不改变视觉呈现的前提下,打乱 DOM 中的文本顺序,以降低直接复制文本的可用性。

Demo overview

How it works

  1. Read typography metrics (font, line-height, available width) from the target element
  2. Compute per-character positions using @chenglou/pretext and canvas.measureText
  3. Wrap each character in an absolutely-positioned <span>
  4. Randomise the DOM order while keeping absolute positions intact

The result: text looks the same but the underlying DOM (and therefore clipboard content) is scrambled.

Packages

PackageDescriptionREADME
article-shuffleCore DOM APIs and layout utilitiespackages/core
react-article-shuffleReact component and hookpackages/react

Quick start

Vanilla

sh
pnpm add article-shuffle
ts
import { shuffleAll, shuffleElement } from 'article-shuffle' // Shuffle a single element shuffleElement(document.querySelector('p')!) // Shuffle all matching descendants shuffleAll(document.querySelector('article')!)

React

sh
pnpm add react-article-shuffle
tsx
import { ShuffleText } from 'react-article-shuffle' export function ArticlePreview() { return ( <ShuffleText blocks={[ 'The first paragraph stays visually readable.', 'The copied result no longer follows the original reading order.', ]} blockAs="p" /> ) }

Demo

PageLink
Main demohttps://shuffle-article.vercel.app
Playgroundhttps://shuffle-article.vercel.app/playground
Main demoPlayground
Main demoPlayground

Development

[!NOTE]
Requires Node.js ≥ 20 and pnpm 10.

sh
pnpm install # install dependencies pnpm dev # start demo dev server pnpm check # type-check the workspace pnpm test # run tests pnpm build # full verification build (check → test → packages → demo)

Workspace layout

shuffle-article/
├── packages/core       # publishable core library
├── packages/react      # publishable React wrapper
└── apps/demo           # Vite demo app

Contributors

Showing top 1 contributor by commit count.

View all contributors on GitHub →

This article is auto-generated from Innei/shuffle-article via the GitHub API.Last fetched: 6/27/2026