source-code/
snakey-extension
Public
typescript36 lines792 B
import { useState, useEffect } from 'react';
import Game from './Game';
function ScoreDisplay() {
const [score, setScore] = useState(0);
useEffect(() => {
const handleUpdate = (e: Event) => {
setScore((e as CustomEvent).detail);
};
window.addEventListener('snakey-score-update', handleUpdate);
return () => {
window.removeEventListener('snakey-score-update', handleUpdate);
};
}, []);
return <span>{score}</span>;
}
function App() {
return (
<>
{/* Floating score display positioned at the top of the browser viewport */}
<div id="score-display">
<div className="score-dot"></div>
<ScoreDisplay />
</div>
{/* Immediately mount the Game component */}
<Game />
</>
);
}
export default App;
About
Snakey Browser Extension is a cross-browser extension built using Manifest V3 that injects a playable Phaser 3 game onto any active tab. It parses the page DOM, turns HTML elements into target coordinates, and features custom chomp/collapse animations. It supports both Chromium (background service worker) and Firefox (background scripts), implements a Canvas-based rendering fallback to bypass strict WebGL CORS limitations, and applies fully container-scoped vanilla CSS overrides to prevent style bleeding on host pages.
linkrasis.me
Browser ExtensionChrome MV3Firefox MV3PhaserReactTypeScriptVite