# JongVoter

A real-time voting tracker for YouTube and Twitch live stream chats. Viewers vote by typing in chat, and the app displays results on an interactive bar chart with drag-to-combine, source splitting, sorting, and more.

## Running the App

### Option 1: Launch the executable (recommended)

Double-click **JongVoter.exe** to start the app. A console window will appear showing the URL (usually `https://localhost:5001`). Open that URL in your browser.

> If Windows SmartScreen blocks the app, click **More info** then **Run anyway**.

### Option 2: Run from source

If you have the .NET 9 SDK installed, open a terminal in the project folder and run:

```
dotnet run
```

## YouTube Setup

1. **Get a YouTube API Key**
   - Go to [Google Cloud Console](https://console.cloud.google.com/)
   - Create a new project (or select an existing one)
   - Navigate to **APIs & Services > Library**
   - Search for **YouTube Data API v3** and click **Enable**
   - Go to **APIs & Services > Credentials**
   - Click **Create Credentials > API key**
   - Copy the key (optionally restrict it to YouTube Data API v3 only)

   > The free tier provides 10,000 quota units per day. Each chat poll costs 5 units, so you can make roughly 2,000 requests per day.

2. **Start Tracking**
   - Paste the **YouTube Live Stream Video ID** (the part after `v=` in the URL, e.g. `dQw4w9WgXcQ`) or the full URL
   - Enter your **API key** (click the **?** button next to the field if you need help)
   - Click **Start Tracking Youtube**

## Twitch Setup

- Enter the **Twitch channel name** (or full URL) and click **Start Tracking Twitch**
- No API key is needed (connects via anonymous WebSocket)

## Using the App

1. **Edit Registry** - Define candidates and their aliases. Viewers can type any alias to vote for a candidate. You can swap a candidate name with one of its aliases using the swap button.
2. **Open the Poll** - Click the OPEN/CLOSED button to toggle voting.
3. **Watch the Chart** - Votes appear in real time on the bar chart.
   - Drag bars onto each other to combine categories
   - Drag bars to the trash bin to remove them
   - Toggle source split to see YouTube vs Twitch votes separately
   - Sort by most votes, most YouTube, or most Twitch
   - Use the **+** button in the toolbar to add temporary candidates or aliases mid-poll
4. **Scoreboard** - Manually track game scores for participants (independent of voting). Click the scoreboard title to rename it.
5. **Pop-out Windows** - Click the pop-out button on the chart or scoreboard to open them in separate windows. Useful for OBS Window Capture so the chart and scoreboard each have their own stable capture area.
6. **Dark Mode** - Toggle with the moon/sun button. Pop-out windows have their own independent toggle.

## Debug Mode

Click the **bug icon** in the chart toolbar to open the debug panel. This is useful for testing your registry and voting setup without needing real viewers.

- **Log votes** - Show each incoming vote in the console
- **Highlight** - Highlight recognized votes in the chat display
- **Simulate votes** - Generate a batch of random votes from your registry. Set the count, choose YouTube/Twitch sources, and click **Go**
  - **Yap mode** - Simulated users send multiple messages (useful for testing the one-vote-per-user filter)
  - **Mahjong mode** - Simulates votes based on a random 14-tile mahjong hand
  - **Strict mode** - Some simulated messages are exact alias matches (useful for testing strict voting)
- **Manual send** - Type a username and message to inject a single chat message as if it came from YouTube or Twitch
