raingart / Nova-YouTube-extension

Apache License 2.0
207 stars 10 forks source link

[Feature] Reposition Closed Captions #183

Open alkaris2 opened 1 month ago

alkaris2 commented 1 month ago

Some YouTube videos and their infinite wisdom like to throw the subtitles box all the way to the top of the screen, leaving a massive box blocking the center half of the video. If I didn't have the Window Opacity transparency set to 75% you just see a big black box covering the screen. It's controlled by .caption-window property bottom: 0% important!; while you can set this to 100% to make the window opacity disappear completely, it doesn't move the position of the CC back to the bottom of the screen.

image image

raingart commented 1 month ago

youtube gets subtitles from file https://www.youtube.com/api/timedtext?v=&

The subtitle format is a bit confusing, and has different levels of positioning: Screenshot_1

I once wrote a prototype for intercepting and modifying subtitles: https://gist.github.com/raingart/732a52177688385445770d136f3459c3

with its help you can intercept and modify subtitles here is an example of a video with 3 types of subtitles (2 at the top and 1 at the bottom) https://www.youtube.com/watch?v=-kBqdNqqIoY

Screenshot_2

Screenshot_3

To change styles you can use the provided functionality or scripts like https://greasyfork.org/en/scripts/501239

for modification try adding to Stylus

.ytp-caption-window-top .captions-text {
   background-color: blueviolet;
   border: 3px solid red;
   position: absolute;
   bottom: 0;
}

but keep in mind that if there are 3 lines of subtitles, as in the example, gaps are possible. The safest is to replace subtitles and move to the bottom and remove intersections. Or raising your own subtitle display module. But this may be done by me sometime in the future