GitHub - AdmTal/scratch-off

1 min read Original article ↗

Scratch-Off

The open source repo for scratchy-lotto.com.

Drop a script tag on any page. Boom — it's a lottery ticket now.

Users scratch to reveal your content. It's dumb and delightful.

What you get

  • Looks like a real scratch ticket (silver, shiny, the whole thing)
  • Works on phones and desktop
  • Makes scratchy sounds
  • Little paint flakes fall off as you scratch
  • Auto-reveals at ~60% scratched
  • Zero dependencies

Install

Script tag. Done.

<script src="https://cdn.jsdelivr.net/npm/scratch-off@latest/dist/scratch-off.umd.js"></script>

Or npm if that's your thing:

That's it. It auto-runs.

How it works

  1. Scans your page
  2. Throws a scratch layer on top
  3. User scratches
  4. Particles fall
  5. 60% scratched = overlay fades

Dev stuff

npm install        # setup
npm run dev        # dev server
npm run build      # build it

Outputs to dist/ in a few formats (ES, UMD, IIFE).

Browser support

Modern browsers. You're fine.

License

MIT

Contributing

Pull requests are welcome! If you have any ideas to improve this project, feel free to open an issue or submit a PR.