A simple javascript library for adding easter eggs to web pages
deno add @egamagz/paska-ovo
npx jsr add @egamagz/paska-ovo
bunx jsr add @egamagz/paska-ovo
Check the JSR page for more details.
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.
Inspired by the project Egg.js and La Velada Web. Created by EGAMAGZ.
MIT License