Skip to main content

A simple javascript library for adding easter eggs to web pages

Works with
This package works with Bun
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Browsers
JSR Score
100%
Published
2 weeks ago

Paska Ovo

Paska

A simple javascript library for adding easter eggs to web pages

JSR GitHub License GitHub Release

Installation

For Deno

deno add @egamagz/paska-ovo

For Node.js

npx jsr add @egamagz/paska-ovo

For Bun

bunx jsr add @egamagz/paska-ovo

For other package managers

Check the JSR page for more details.

Example

import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo";

const paskaOvo = new PaskaOvo()
  .addCode({
    code: HistoricalCodes.BarrelRoll,
    onFound: () => {
      //...
    },
    onFinish() {
      // ...
    },
    duration: 1000,
    tag: "Barrel Roll"
  })
  .addCode({
    code: HistoricalCodes.Konami,
    onFound: () => {
      // ...
    },
    tag: "Konami"
  })
  .addCode({
    code: ["a", "w", "e", "s", "o", "m", "e"],
    onFound: () => {
      // ...
    },
    tag: "Awesome"
  })
  .addCallback((easterEgg) => {
    alert(`You found the easter egg: ${easterEgg.tag}`)
  });

// Listen to keyboard events
document.getElementById("add-easter-egg").addEventListener("click", () => {
  paskaOvo.listen();
});

// Stop listening to keyboard events
document
  .getElementById("remove-easter-egg")
  .addEventListener("click", () => {
    paskaOvo.stop();
  });

Alternatively, it's possible to define the easter egg using the constructor:

import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo";

 const paskaOvo = new PaskaOvo({
  code: HistoricalCodes.Konami,
  onFound: () => {
   alert("Gradius");
  },
  tag: "konami-code",
 }).addCallback((easterEgg) => {
  console.log("Actual easter egg:", easterEgg.tag);
  console.log("Easter egg's code:", easterEgg.code);
 });

 paskaOvo.listen();

Check the example with source code.

Credits

Inspired by the project Egg.js and La Velada Web. Created by EGAMAGZ.

License

MIT License

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @egamagz/paska-ovo

Import symbol

import * as mod from "@egamagz/paska-ovo";

Add Package

npx jsr add @egamagz/paska-ovo

Import symbol

import * as mod from "@egamagz/paska-ovo";

Add Package

yarn dlx jsr add @egamagz/paska-ovo

Import symbol

import * as mod from "@egamagz/paska-ovo";

Add Package

pnpm dlx jsr add @egamagz/paska-ovo

Import symbol

import * as mod from "@egamagz/paska-ovo";

Add Package

bunx jsr add @egamagz/paska-ovo

Import symbol

import * as mod from "@egamagz/paska-ovo";