raingart / Nova-YouTube-extension

Apache License 2.0
198 stars 9 forks source link

Couple of bugs/quirks and a feature request. #95

Closed Eisys closed 11 months ago

Eisys commented 11 months ago

First of all I want to say Thank You! for this amazing script.

I was holding onto to Iridium(latest normal version before it got nuked) mainly for its "player visible while scrolling" feature. Iridium had the best version of it out of all others I've tried. Slowly Iridium's features broke that I supplemented with other addons/script but luckily the small player feature kept working...until a couple weeks ago. So I had to find a replacement and luckily came across this script. And your version works just as well. It comes on when scrolling down 50% of the video, and I was able to customize the placement and other things with my own CSS: https://pastebin.com/MgTAAVWM So a big thanks!!

First the bugs/quirks:

no1 "Player shortcuts always active" It doesn't seem to work right away, after clicking outside of video. It works correctly when on a fresh/brand new video tab. But when I have clicked outside the video and then change volume with arrow keys, the first input scrolls the page, THEN starts changing volume. Same thing after every click outside of video.

no2 "Float player progress bar" Another great feature that I currently use a separate script for. Nova's one is a bit glitchy. When it first 'activates,' the main progress bar can be 100% for a short bit and/or the buffer bar doesn't load in. Both can be seen in this example: https://i.imgur.com/HT1OVqJ.gif This is after a CTRL+F5 refresh. The glitchiness isn't THE biggest deal but is still annoying. And it varies video-to-video exactly what happens.

The script I use works flawlessly all the time, BUT doesn't have chapter dots, which Nova has, so I'd prefer to use Nova's. https://greasyfork.org/en/scripts/394512-youtube-progressbar-preserver

And a small request with this feature, I'd personally prefer if non-chaptered videos' progress bars had the full width background. Videos with chapters have a background but ones without don't, you only see progress and buffer bars, like in the gif above. I fixed this with CSS by setting this height to 2px(same as my progress bar) to make the background visible.

nova-player-float-progress-bar {

height: 2px !important;

} But I feel like this should be default behaviour or maybe make it adjustable. Some might prefer not to see it, etc.

no3 "Stop play channel trailer " This simply never works for me on any channel. But I redirect to /videos anyway so not a big deal.

no4 "Redirect Shorts to regular (watch) URLs" The short plays as a short, then gets redirected to normal video URL. The script I use currently instantly starts as a video URL, or atleast does it alot quicker so it's not noticeable https://greasyfork.org/en/scripts/439993-youtube-shorts-redirect But again not a big deal since I have shorts disabled in the parts of Youtube I visit so this very rarely comes up.

no5 "Default tab on channel page " Mine is set to videos and 'click' variant(though same pretty much applies with 'redirect'). Works fine but the redirect time seems "unnecessary", Iridium used to do it instantly, sort of directly went to /videos whether you middle/CTRL clicked to new tab or stayed on the page, it was on /videos right away instead of doing a little redirect dance that Nova does. Perhaps that's not possible anymore, I'm not sure. I know f**k all about coding. I'm just listing what I find buggy/weird.

no6 "YouTube logo link" Works fine when middle/CTRL clicking to new tab but doesn't work when normal clicking. Youtube's in-page/SPF loading seems to mess it up perhaps. The URL tooltip(that comes up when you hover over links) at the bottom left of the browser does say "***.youtube.com/feed/subscriptions" but yeah, simply goes to youtube.com when normal clicking on it. Again, the script I use currently works fine. https://greasyfork.org/en/scripts/13582-youtube-logo-link-to-subscriptions-feed

And the feature request:

Please add an option to disable Youtube's volume normalization. Currently I use this script: https://gist.github.com/abec2304/2782f4fc47f9d010dfaab00f25e69c8a

And that's it. You have made an amazing Youtube customizer. If these small issues were fixed/changed and the feature added, I could get rid of so many separate scripts.

raingart commented 11 months ago

I'll do it tomorrow weekend if I have free time. Now I can answer some questions

"Player shortcuts always active" ... clicked outside the video

Yes, I forgot that you can click with the mouse and redirect the focus. The current implementation takes into account only keyboard keydown. In fact, it would be correct to call the plug-in - "remove the blue borders of the player elements with focus." But it doesn't sound as cool as "Player shortcuts always active" UPD: I looked, it turns out that for some reason I disabled "listening for click events". Perhaps there were problems with other plugins? For example #90, #87

"Float player progress bar"

There are 3 possible reasons. In short, the whole point is that for optimization, updates are disabled if the panel is hidden. But because of "css: transition: transform" there is a lag when initializing. I killed it when when going to the next page. I'll try to fix it.

I will mention that in the cad of each plugin there are links to existing alternatives. And some of them use blends of the original progressbar. This solution is much simpler, but the problem is that chapters are not always rendered. I myself use another plugin "Control panel below the player". And serious compatibility issues between them.

height: 2px !important;

I did not quite understand. There is an option to change this setting in the settings: Screenshot_1

I feel like this should be default behaviour

Can you explain in more detail. I don't understand. What background are you talking about? And how did you solve the gap by increasing the height

Stop play channel trailer

UPD find #c4-player[playing-mode] and replace #c4-player.playing-mode

"Redirect Shorts to regular (watch) URLs"

the implementation is the same: Screenshot_2

Plugin activation speed problem. Nova starts up quite slowly. It has to do with internal mechanisms. And not all tasks can be completed in Nova. For example, those related to experimental flags or youtube configuration before launch or during launch. This leads to the fact that Nova, in order to reduce the load and reduce the impact of the speed of launching youtube itself, will only start after the initial configuration stage has been completed. And I decided that in the future with a large number of plugins, this can significantly affect stability and speed. Also, the plugins have not been tested in this mode of operation and are not expected to be launched not "after everything"

here is a way to speed up the launch of Nova replace:

function landerPlugins() {
   processLander();
   function processLander() {
      const plugins_lander = setInterval(() => {
         const domLoaded = document?.readyState != 'loading';
         if (!domLoaded) return console.debug('waiting, page loading..');
         clearInterval(plugins_lander);
         console.groupCollapsed('plugins status');
         Plugins.run({
            'user_settings': user_settings,
            'app_ver': GM_info.script.version,
         });
      }, 500);
   }

on

Plugins.run({
            'user_settings': user_settings,
            'app_ver': GM_info.script.version,
         });

or comment out

Screenshot_4

"Default tab on channel page "

it has to do with the way it is implemented. Iridium directly changes the "link endpoint". But this method is extremely unreliable. I went the other way 90% of Nova features are loosely coupled to the internal API. And much more with DOM.

You can do amazing things if you start using the API to its full potential. But that's what became the Achilles' heel of "Youtube Center" and Iridium and hundreds of other scripts. They relied too much on the API. I will not repeat such a mistake. And even more I abandoned the monolithic architecture that ruined them. https://greasyfork.org/en/scripts/397094-youtube-video-preview-and-ratings-keyless

"YouTube logo link"

this script is somewhat tricky. It inserts an element that starts mimics an API call subButton.innerHTML = '<a id="endpoint" class="yt-simple-endpoint style-scope ytd-guide-entry-renderer" tabindex="-1" role="tablist" title="Subscriptions" href="/feed/subscriptions">';

volume normalization

And can you explain to me what is the problem of normalization? I have always had enough of an external amplifier for quiet video. Does she distort the sound? I missed this feature for two reasons: 1) because I didn't experience any problems. 2)And often this will fail due to some rules in browsers (changes in audio/video context needs to be initiated by trusted user events). I once suffered with the PIP launch function

Eisys commented 11 months ago

I'll do it tomorrow weekend if I have free time. Now I can answer some questions

These are not critical bugs by any means so I hope you don't feel rushed. Thanks for the quick action and for a detailed response.

"Float player progress bar"

There are 3 possible reasons. In short, the whole point is that for optimization, updates are disabled if the panel is hidden. But because of "css: transition: transform" there is a lag when initializing. I killed it when when going to the next page. I'll try to fix it.

Ah I guessed it wasn't working in the background too. Thanks for looking into it.

I will mention that in the cad of each plugin there are links to existing alternatives. And some of them use blends of the original progressbar. This solution is much simpler, but the problem is that chapters are not always rendered. I myself use another plugin "Control panel below the player". And serious compatibility issues between them.

Didn't know about the alternatives, I will check them out.

height: 2px !important;

I did not quite understand. There is an option to change this setting in the settings: Screenshot_1

I feel like this should be default behaviour

Can you explain in more detail. I don't understand. What background are you talking about? And how did you solve the gap by increasing the height

Yes I know about the height setting. The progress bar has 3 layers to it. The background, the buffer bar and the progress bar. The default behaviour of Nova does not show the background on videos without chapters. Example: https://i.imgur.com/Byp466Z.png

If I add this CSS to my Stylus style:

nova-player-float-progress-bar {

height: 2px !important;

} then it does show the background: https://i.imgur.com/mQAxs0D.png In these examples the height of the bar is 9px for clarity but I usually use 2px.

And so I think since videos with chapters have the background shown, it should be shown on all videos. But as I said, some people might prefer not to see the background and only buffer and progress bars.

"Redirect Shorts to regular (watch) URLs"

the implementation is the same: Screenshot_2

Plugin activation speed problem. Nova starts up quite slowly. It has to do with internal mechanisms. And not all tasks can be completed in Nova. For example, those related to experimental flags or youtube configuration before launch or during launch. This leads to the fact that Nova, in order to reduce the load and reduce the impact of the speed of launching youtube itself, will only start after the initial configuration stage has been completed. And I decided that in the future with a large number of plugins, this can significantly affect stability and speed. Also, the plugins have not been tested in this mode of operation and are not expected to be launched not "after everything"

"Default tab on channel page "

it has to do with the way it is implemented. Iridium directly changes the "link endpoint". But this method is extremely unreliable. I went the other way 90% of Nova features are loosely coupled to the internal API. And much more with DOM.

You can do amazing things if you start using the API to its full potential. But that's what became the Achilles' heel of "Youtube Center" and Iridium and hundreds of other scripts. They relied too much on the API. I will not repeat such a mistake. And even more I abandoned the monolithic architecture that ruined them. https://greasyfork.org/en/scripts/397094-youtube-video-preview-and-ratings-keyless

I understand, thanks for the explanation. It makes perfect sense and again, these are not critical bugs that would cause me not to use Nova so it is not a problem if some things take a few milliseconds longer. What's important is that Nova works and keeps working. I still miss Youtube Center, that was one insane script. But yeah, so many scripts/addons try to add a million different features with loads and loads of customization and then they can never keep up with bugs and Youtube changes and they eventually die.

volume normalization

And can you explain to me what is the problem of normalization? I have always had enough of an external amplifier for quiet video. Does she distort the sound? I missed this feature for two reasons: 1) because I didn't experience any problems. 2)And often this will fail due to some rules in browsers (changes in audio/video context needs to be initiated by trusted user events). I once suffered with the PIP launch function

There isn't strictly a problem with it but I just hate that Youtube thinks they have the right to change the volume on videos. Some videos are rather noticeably quieter with normal YT compared to using the script. I find that really stupid and unnecessary. And yeah, reading the comments under the script, it does indeed seem to not always work on every video that has normalization so I can perfectly understand if you don't want to include it.

raingart commented 11 months ago

no1 "Player shortcuts always active" - fixed no3 "Stop play channel trailer " - fixed no6 "YouTube logo link" - fixed volume normalization - added

no2 "Float player progress bar" - partially no4 "Redirect Shorts to regular (watch) URLs" - impossible to implement no5 "Default tab on channel page " - impossible to implement

no2 "Float player progress bar" turns out this is a bug. Why does the container ignore and become invisible when specifying the height of the children. I don't know the reason for this css behavior. I'll try to fix it. As for the oag panel during initialization. - I couldn’t fix it. This turned out to be more difficult than I thought.

no5 "Default tab on channel page " i tried to change internal endpoint but youtube ignores tab activation. I don't know what is the reason.

Regarding "volume normalization" There are several problems. First, there are 2 types of volume. The player and video. Player 0-100 and video some range. From zero to how much. In the video I tested the max value is 0.45. At the max. theoretical 1. That is, the overall volume is reduced 2 times. And nowhere is it indicated how to change this and on the basis of what the limits appear. I did not find any mention of the word "normalization" of the sound either in youtube or in HTML5 examples. Perhaps this is a common name.

Eisys commented 11 months ago

Thank you so much for such quick work! I tried the newer beta.

no1 "Player shortcuts always active" - fixed

Yup it works better, but now I noticed a bug. When the page has been scrolled down, clicking anywhere scrolls the page back up to the video. Probably because you are putting focus on the player on every click. So even clicking on "X replies" under a comment or liking/disliking a comment scrolls the page up to the player on every click. This is tested with "pin player while scrolling" disabled. If it's enabled, then scrolling only happens when the main/large player is still visible. When the small player is on, there is no scrolling

Is there a way you can keep focus on the player without any auto-scrolling? This is a thing in release version Nova as well but it only happens after you click somewhere and then do a keypress, to change volume for example. I just didn't come across it until now because I use "pin player while scrolling"

no3 "Stop play channel trailer " - fixed no6 "YouTube logo link" - fixed volume normalization - added

Yup, these all seem to be fixed. And disabling 'normalization' also seems to be working. Thank You so much!

But, if I might have a tiny question about YT logo link: With the script I use, the logo link works like others in Youtube; they don't refresh the entire page but instead use Youtube's in-page/SPF loading(indicated by the red loading bar at the top of the page). So I was wondering if this could be implemented for the logo as well? But if not, that is no problem, the time difference is marginal at best.

no2 "Float player progress bar" - partially

The background is shown now, thank you. And "float progressbar width 100% on init" also seems to be fixed. Now only the buffer bar sometimes loads in late, sometimes as long as 2-3 seconds. But not a big deal.

no4 "Redirect Shorts to regular (watch) URLs" - impossible to implement no5 "Default tab on channel page " - impossible to implement

Okay, no problem 👍

Eisys commented 11 months ago

Player focus is now indeed fixed in the newest beta. Thank you!

I totally understand about the logo, don't worry about it. I didn't realise that script was so complicated. Nova existing at all and working is a lot more important, thank you for your hard work. :)

Yeah the people in the comments of the normalization script are a bit weird 🤣

It was an amusing read. Thanks! And yes, you can close the topic. All is good. 👍👍

EDIT: Actually I did come across a new bug, this one is in release Nova too so maybe it should be a new Issue on its own. After a refresh of the page when a video starts from middle(previously viewed video or a url with timestamp), the video resets to the same time it started on when the progress bar loads in. It's hard to explain, I hope this GIF helps make sense of it. https://gifyu.com/image/SckGt After the first refresh, I let the controls disappear and you can see the video jump back to where it started. After the 2nd refresh I hover over the player longer to keep progress bar from loading in. Once it does, the video once again jumps back the original point.

Eisys commented 11 months ago

Okay figured it out. I imported my main settings and it happened on then new profile so it is a Nova thing still. It is "No scroll to top when clicking timestamps" that is causing this. Only that setting and progress bar can be enabled and it happens.

raingart commented 11 months ago

try find and replace this line

if (evt.isTrusted && !evt.target.matches('a[href*="&t="]')) return;

on

if (!evt.isTrusted || !evt.target.matches('a[href*="&t="]')) return;
Eisys commented 11 months ago

That fixes it. Man you work fast :D Thank you!

Now I do want to mention one last thing I found during all this testing. The "Video quality" option being enabled sometimes makes the player load twice. Especially after a page refresh, the video starts for like 0.5-1 seconds, then goes black and starts again.

With that setting off, there is no reload of the player. Sometimes, instead of double-loading, it just makes the player take longer to load than with it off.

I'm not sure how you are forcing quality of video so this might not be fixable but just thought I would mention it, just in case.

Example here:https://streamable.com/7856pf I disabled Nova entirely because it was faster but same result if I simply turn "Video Quality" setting off

raingart commented 10 months ago

@Eisys I rewrote the colume normalization code. Earlier, I used the methods used in the example. But they are suboptimal and crooked - crutches.

These two scripts helped me a lot https://greasyfork.org/en/scripts/397686-youtube-music-fix-volume-ratio/code https://stackoverflow.com/questions/34326267/how-can-i-wrap-the-html5-video-elements-currenttime-property

I am sure that someone unequivocally implemented also earlier. But alas, I can't find it. And the current implementation is the best I know. I don't know if the problem is with other sites. But this solution is universal. If necessary, I can adapt for other players.

Now the normalization works completely correctly. Try https://gist.github.com/raingart/12695858bd13e356ac87350edf651193