YouTube Subtitle Fix

Improves YouTube subtitles with smarter line wrapping, readable styling, customizable settings panel, and YouTube header icon.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Аўтар
David33
Усталяванняў за дзень
2
Усяго ўсталяванняў
26
Рэйтынг
0 1 0
Версія
1.2.10
Створаны
23.04.2026
Абноўлены
05.05.2026
Памер
57.9 КБ
Ліцэнзія
Н/Д
Ужываецца на

# YouTube Subtitle Fix

Improves how YouTube subtitles look and behave with smarter line wrapping, better readability, optional per-line background boxes, and cleaner handling of translator notes.

## Files

- `tampermonkey.user.js` - Tampermonkey userscript version
- `enhancer-for-youtube.js` - script version for Enhancer for YouTube

## What it does

- Changes subtitle text color
- Changes subtitle size in normal mode and fullscreen mode
- Lets Tampermonkey users save subtitle size preferences through the userscript menu
- Can automatically keep YouTube's default subtitle size in previews, mini player, and other small player contexts
- Adjusts subtitle background color and opacity
- Supports one shared background box or per-line background boxes
- Keeps subtitles centered
- Lets you move subtitles higher on the screen
- Adds text shadow for better readability
- Wraps long lines automatically
- Tries to keep line breaks more natural and balanced
- Prefers two-line subtitles when possible
- Allows three lines only when needed
- Keeps translator notes in square brackets together
- Preserves a two-line layout when a translator note is already on its own line

## Main settings

- `textColor` - subtitle text color
- `backgroundColor` - subtitle background color as RGB values
- `backgroundOpacity` - background transparency from `0` to `1`
- `fontSizeNormal` - subtitle size in normal mode
- `fontSizeFullscreen` - subtitle size in fullscreen mode
- `subtitleSizeMode` - `default`, `script`, or `custom` subtitle size mode
- `preferYouTubeSizeInSmallPlayers` - keeps previews and mini players on YouTube's default subtitle size
- `customFontSizeNormal` / `customFontSizeFullscreen` - saved subtitle sizes for custom mode
- `lineHeight` - spacing between subtitle lines
- `maxWidthPercent` - maximum subtitle width relative to the video width
- `enableAutoLineBreaks` - turns smart wrapping on or off
- `preserveAutoGeneratedCaptions` - keeps YouTube auto-generated captions stable by not rewriting their text
- `maxCharsPerLine` - target line length for smart wrapping
- `perLineBackground` - separate background per line or one shared box
- `paddingY` / `paddingX` - inner spacing inside the background box
- `borderRadius` - roundness of subtitle background corners
- `offsetNormal` / `offsetFullscreen` - subtitle height from the bottom
- `extraPerLine` - extra upward offset for multi-line subtitles
- `textShadow` - subtitle text shadow

## Safe starter preset

```js
lineHeight: 1.20,
maxWidthPercent: 78,
enableAutoLineBreaks: true,
preserveAutoGeneratedCaptions: true,
maxCharsPerLine: 44,
perLineBackground: true,
```

## Install

### Tampermonkey

1. Install the Tampermonkey browser extension.
2. Create a new script.
3. Replace the template with the contents of `tampermonkey.user.js`.
4. Save and open any YouTube video.
5. Optional: use the Tampermonkey menu to switch between YouTube default subtitle size, the script's subtitle size, or your own saved custom size.
6. Optional: keep YouTube's default subtitle size in previews and mini player while still using your preferred size in normal and fullscreen playback.

### Enhancer for YouTube

1. Open Enhancer for YouTube settings.
2. Find the custom script section.
3. Paste in the contents of `enhancer-for-youtube.js`.
4. Save and reload YouTube.

## Notes

- This script only changes how subtitles are displayed.
- It does not modify the subtitle file itself.
- Final behavior can still depend on how YouTube renders captions internally.
- Best results usually come from adjusting `maxWidthPercent`, `maxCharsPerLine`, and `lineHeight` together.


## Changelog

### 1.2.10

- Reduced the brief unformatted subtitle flash by running subtitle processing immediately on caption DOM changes, then keeping the existing animation-frame pass.
- Hid YouTube's temporary `English / Click for settings` caption info overlay when subtitles are toggled on.

### 1.2.6

- Only small bug fixes


### 1.2.5

- Fixed the `YT Sub Fix` button appearing in live chat, embedded YouTube players, and Google preview windows.
- Improved subtitle positioning so captions are placed correctly earlier, reducing the bottom-position flicker before the script-applied offset appears.


## Additional fixes and improvements

- Added a background mode switch in the settings panel.
- `Line BG` uses a separate black background behind each subtitle line.
- `Box BG` uses one shared black background box behind the whole subtitle.
- Improved per-line background rendering so multi-line subtitles look closer to YouTube's original style.
- Removed rounded corners from per-line subtitle backgrounds to avoid small gaps between stacked lines.
- Improved the settings panel layout so the background color, opacity, and background mode controls are easier to use.
- Fixed the ON/OFF switch so turning the script off restores YouTube's original subtitle styling more cleanly.


### 1.2.4

- Added YouTube header button: YT Sub Fix
- Added in-page settings panel
- Added text color picker
- Added background color picker
- Added background opacity slider
- Added subtitle size mode controls
- Added normal and fullscreen custom size controls
- Added subtitle position controls
- Added smart line wrapping controls
- Added visible line length value on wrapping buttons
- Removed Tampermonkey dropdown menu commands so only the script name appears
- Settings are saved automatically


## Live preview tip for line wrapping


The **Line shorter** and **Line longer** settings are saved immediately, but YouTube does not always refresh the visible subtitle layout in normal view right away.
If the subtitle line wrapping does not visibly update while the video is playing, press **F** to switch between normal and fullscreen mode.
This usually forces YouTube to redraw the subtitle layer, so the updated line wrapping becomes visible immediately.



### 1.2.0

- Added saved Tampermonkey subtitle size settings.
- Added subtitle size modes: YouTube default, script size, and custom size.
- Added automatic YouTube default sizing for previews, mini player, and small player contexts.
- Updated README with the new size settings.

### 1.0.4

- Improved subtitle centering so captions are centered immediately when rendered.

### 1.0.2

- Preserved auto-generated captions to avoid flickering and layout glitches.

## Screenshots

![YouTube Subtitle Fix settings panel](screenshotNEW.jpg)


## Greasy Fork

[Greasy Fork script page](https://greasyfork.org/en/scripts/575046-youtube-subtitle-fix-smart-line-wrapping-better-readability)

## Sponsor

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/N4N0XO52O)