Cocogoat Documentation
repository·main·Indexed 22 days ago
https://github.com/yuehaiteam/cocogoatA web-based utility toolbox for Genshin Impact players featuring local achievement recognition via PaddleOCR and onnxruntime. It provides tools for achievement management, browser-side OCR for privacy, and a lightweight client (cocogoat-control) for simulating mouse and keyboard interactions. The project is built with TypeScript and Vue.js, supporting integration via iframes and communication through the postMessage API.
What's inside cocogoat
- Cocogoat is a web-based toolbox for Genshin Impact. It provides tools for achievement recognition and management. The project is designed to be lightweight and accessible across different platforms (Windows, non-Windows, and mobile) while offering a web interface that can be integrated easily.
Communicate with the scanner via postMessage
mainThe scanner interacts with the parent application using the
postMessageAPI. All messages follow a standard format:{ app: 'cocogoat.scanner.achievement', event: 'ready' | 'result', // Sent from scanner to parent command: 'start' | 'reset', // Sent from parent to scanner data: ... }{ app: 'cocogoat.scanner.achievement', event: 'ready', data: undefined }Understand Achievement Scanning features
mainThe achievement scanning feature uses a specialized version of PaddleOCR and onnxruntime to perform Optical Character Recognition (OCR) directly within your web browser.
Key capabilities:
- Browser-based OCR: No data is sent to a server for recognition.
- Lightweight Client: Uses a client (approx. 440 KB) to enable necessary automation.
- Language Support: Currently supports both Chinese and English.
- Mobile Support: Capable of recognizing achievements from mobile phone screenshots.
Achievement Management Features
mainThe management suite allows users to:
- Filter achievements by category, task, or commission.
- View achievement trigger conditions (e.g., displaying the specific task name if a task triggered the achievement).
Understand Achievement Management features
mainThe achievement management system allows users to organize and inspect their progress.
Key capabilities:
- Filtering: Filter achievements by category, task, or commissions.
- Trigger Conditions: View the specific conditions required to trigger an achievement. If an achievement is tied to a task, the task name is displayed.
Achievement Recognition Features
mainCocogoat supports local achievement recognition directly in the browser using:
- PaddleOCR and onnxruntime for local client-side recognition.
- Mobile scanning: Supports scanning screenshots via mobile devices.
- Simulated clicks: Can be paired with a lightweight client (approx. 440 KB) to implement simulated mouse/keyboard clicks, bypassing browser limitations.
Use cocogoat-web locally via singlefile build
mainTo run cocogoat-web without an internet connection or as a standalone tool, you can use the single-file build.
- Download the
singlefile buildfrom the GitHub Actions workflow. - Open the downloaded local HTML file using Chrome version 91 or higher.
- Download the
Run and build cocogoat-web locally
mainFor developers contributing to the project, use
pnpmto manage the development and build processes. The project supports bothVite(recommended for development) andwebpack(recommended for deployment).Development Commands
# Run the development server (uses Vite) pnpm serve # Build the project (uses webpack) pnpm build # Build as a single HTML file (uses Vite) pnpm build:singlefilepnpm serve pnpm build pnpm build:singlefileIntegrate Cocogoat Web via iframe
mainCocogoat Web is a web-based project that can be integrated into other web-based applications using an
<iframe>. To ensure the scanner can capture the screen for achievement recognition, you must include theallow="display-capture"attribute in your iframe tag.<iframe src="https://cocogoat.work/frames/achievement-scanner" frameborder="0" allow="display-capture"> </iframe>Set up the Cocogoat development environment
mainThe project is built with
TypeScriptandVue.js. You can use eitherViteorwebpackas the toolchain. It is recommended to useVitefor active development andwebpackfor final testing and deployment.Use
pnpmto run the following commands:# Run locally using Vite pnpm serve # Build production using webpack pnpm build # Build a single-file version using Vite pnpm build:singlefileManage achievements in the AchievementIndex view
mainThe
AchievementIndexcomponent is the primary interface for viewing, searching, and managing game achievements. It provides several key capabilities:Core Features
- Progress Tracking: Displays total completed achievements and potential rewards (e.g., Primogems).
- Filtering & Sorting: Filter achievements by version (including unpublished versions), quest type (
WQfor World Quests,IQfor Daily Commissions,AQfor Archon Quests), and toggle 'Unfinished First' or 'Hide Finished' modes. - Search & Navigation: Search by achievement name, description, or ID. The view supports a 'Locate' mode to jump directly to a specific achievement in the list.
- Data Management:
- Import: Use the
ImportDialogto bring in achievement data. - Export: Use the
ExportDropdownto save achievement progress. - Clear: Options to clear current progress or all progress via
doClear. - Scanner: A
ScannerDialogis available to trigger achievement recognition/scanning.
- Import: Use the
Data Model & State
- Achievement progress is stored in the global
store.value.achievement2object. - Achievement data is categorized into groups (e.g., by version or type) and can be filtered dynamically.
<!-- The component uses several sub-components for its functionality --> <achievement-item :i="achievement" :fin="achievementFin[id]" @check="updateFinished(id)" @input-date="achievementFin[id].timestamp = $event" @input-current="updateCurrent(id, Number($event))" @input-partial="updatePartial(id, $event[0], $event[1])" @click-title="detail = achievement" />Switching installer types via URL query
mainThe installer view supports multiple distribution types (e.g., different regions or platforms) via the
typequery parameter in the URL.- The default type is
pc-cnif no query is provided. - The component uses the
typeparameter to look up the corresponding API endpoint in theurlsconfiguration. - Changing the
typequery parameter triggers a reload of the package data.
- The default type is