/paska-ovo

A simple javascript library for adding easter eggs to web pages 🥚

Primary LanguageTypeScriptMIT LicenseMIT

Paska Ovo

Paska

A simple javascript library for adding easter eggs to web pages

JSR JSR Score 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()
  .addEasterEgg({
    code: HistoricalCodes.BarrelRoll,
    onFound: () => {
      //...
    },
    onFinish() {
      // ...
    },
    duration: 1000,
    tag: "Barrel Roll"
  })
  .addEasterEgg({
    code: HistoricalCodes.Konami,
    onFound: () => {
      // ...
    },
    tag: "Konami"
  })
  .addEasterEgg({
    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