$ show biuuu/BLHXFY
This repository is a userscript/browser extension that provides real-time Japanese-to-Chinese translation for the Granblue Fantasy game website. It intercepts XHR requests to the game's API and modifies JSON responses to replace Japanese text with translations, while also translating HTML content on the page. The application uses a modular architecture with separate translation modules for different game systems (battle, scenario, skills, etc.) and includes a data processing pipeline that converts CSV translation files into JSON format for efficient lookup. Key features include configurable settings, voice subtitles, translator attribution, and optional AI translation fallback.
The LLM identified 4 files worth highlighting for reuse:
Provides a whitelist-based HTML sanitization approach using DOMPurify with special handling for game-specific allowed patterns. Demonstrates non-obvious skill by combining a robust sanitization library with application-specific whitelist rules in a clean, reusable way. Could be extracted for any web application needing to safely render user-generated content with specific allowed HTML patterns.
Implements a custom event system for communication between different parts of the extension using Standard CustomEvent API. Shows clean decoupling pattern where components communicate through a global event bus without direct dependencies. The pattern is highly reusable - any application could adopt this exact approach for internal communication between modules.
Implements a smart caching system that uses sessionStorage to store data with hash-based cache invalidation. Automatically refreshes cached data when source files change by comparing hashes from manifest.json. Demonstrates non-obvious skill in cache management - avoids unnecessary refetching while ensuring data freshness. The pattern is broadly applicable to any web app that needs to cache data with automatic updates when source data changes.
Provides a unified interface for making HTTP requests that works with both standard fetch and GM_xmlhttpRequest (for userscript environments). Abstracts away the differences between environments while maintaining a consistent Promise-based API. Demonstrates non-obvious skill in handling the complexities of userscript development where standard fetch may not be available. Highly reusable for any userscript or browser extension that needs to work in both regular web and userscript contexts.