source-code/
snakey-extension
Public
typescript35 lines868 B
import { useEffect, useRef } from 'react';
import Phaser from 'phaser';
import { SnakeScene } from './game/SnakeScene';
export default function Game() {
const gameRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!gameRef.current) return;
const config: Phaser.Types.Core.GameConfig = {
type: Phaser.CANVAS,
width: window.innerWidth,
height: window.innerHeight,
parent: gameRef.current,
transparent: true,
physics: {
default: 'arcade',
arcade: {
gravity: { x: 0, y: 0 }
}
},
scene: SnakeScene
};
const game = new Phaser.Game(config);
return () => {
game.destroy(true);
};
}, []);
return <div ref={gameRef} id="phaser-game-container" className="fixed top-0 left-0 w-screen h-screen pointer-events-none z-[999999] overflow-hidden" />;
}
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