Automcatically switches to your pre-selected resolution. Enables premium when possible.
< Σχολιασμός για τον κώδικα Youtube HD Premium
TLDR: This script already sets the quality early by default.
So after looking into this I am fairly certain that this has something to do with your setup in particular. YouTube changed how they load the video player a while ago and so this script was also changed to ALWAYS set quality early, as it is no longer necessary for the player to fully load for quality settings to apply (premium bitrate has to wait for YouTube to finish their “authentication procedures” and is an exception). Your issue is likely due to some factors such as any extra extensions/scripts that you have as I am unable to replicate your issue across multiple browser + script loader + YouTube UI + premium/non-premium combinations. It would help if you could clarify those and also give some examples of which videos in particular that you are having issues on.
Also do you mean that adisib’s script works right now and is able to set resolution early while this script cannot?
TLDR: This script already sets the quality early by default.
So after looking into this I am fairly certain that this has something to do with your setup in particular. YouTube changed how they load the video player a while ago and so this script was also changed to ALWAYS set quality early, as it is no longer necessary for the player to fully load for quality settings to apply (premium bitrate has to wait for YouTube to finish their “authentication procedures” and is an exception). Your issue is likely due to some factors such as any extra extensions/scripts that you have as I am unable to replicate your issue across multiple browser + script loader + YouTube UI + premium/non-premium combinations. It would help if you could clarify those and also give some examples of which videos in particular that you are having issues on.
Also do you mean that adisib’s script works right now and is able to set resolution early while this script cannot?
I am the same person who made this review on a different account. I was having issues on 4k 60 fps videos like this (https://www.youtube.com/watch?v=LXb3EKWsInQ). The adisib’s script used to be able to set the resolution the second the video loaded with no delay but then the script overall stopped working randomly on some videos which is probably due to the change that you mentioned regarding the youtube video player changes. I was able to slightly modify your script so that now that there is no delay in changing the resolution on my end. After making the change it allows for the intended behavior of changing the resolution of videos early during the very first second of the video when it starts but there is still a slight delay to change the resolution to the max resolution on very short videos that are 1 to 2 minutes long (https://www.youtube.com/watch?v=vxi-29dqsQ0). There is probably nothing that can be done about the short delay still being present on 1 to 2 minute videos even after I making the change to the script because it probably has something to do with the youtube player itself now. It would be nice if you would be willing to incorporate my change though if possible since its just 1 line and it would be helpful for anyone else experiencing the issue I was having.
I changed this part of your script in your main function:
win.addEventListener("loadstart", () => { setResolution(userSettings.targetResolution); }, true);
To this:
win.addEventListener("yt-navigate-finish", () => { setResolution(userSettings.targetResolution); });
Hey so I looked into this issue and the current hypothesis is that loading very large videos on very fast internet would cause the video content to load before the video player can handle the video resolution. I have made a new update that simply re-checks the playback quality, and if it detects that the setting has not yet applied then it will re-trigger the function to force YouTube to update (essentially what adisib's flushBuffer does, but YouTube made it a built-in function now).
The event listener was changed because I noticed that the script applied settings much too late for the grand majority of videos (1080p non-HDR stuff). 4k HDR was definitely not considered when I first wrote this script, but the new update (2024.08.09) should(?) fix that.
I appreciate all the feedback. So please do tell me if the new update works or not. I am hesitant to revert the changes to the event listener as it impact the common experience too much more my liking.
Hey so I looked into this issue and the current hypothesis is that loading very large videos on very fast internet would cause the video content to load before the video player can handle the video resolution. I have made a new update that simply re-checks the playback quality, and if it detects that the setting has not yet applied then it will re-trigger the function to force YouTube to update (essentially what adisib's flushBuffer does, but YouTube made it a built-in function now).
The event listener was changed because I noticed that the script applied settings much too late for the grand majority of videos (1080p non-HDR stuff). 4k HDR was definitely not considered when I first wrote this script, but the new update (2024.08.09) should(?) fix that.
I appreciate all the feedback. So please do tell me if the new update works or not. I am hesitant to revert the changes to the event listener as it impact the common experience too much more my liking.
I did notice an improvement in setting the resolution early at the very first second of most videos when they start with your new update but there still seems to be a few edge cases for random videos (https://www.youtube.com/watch?v=NNS5Piu-EII) (https://www.youtube.com/watch?v=evN1YwKLcwY). The videos I gave as an example in this reply are long but there would still be a slight 7 to 10 second delay to switch the default resolution to 4k 60 fps. I believe you are correct in your "very large videos on very fast internet would cause the video content to load before the video player can handle the video resolution" observation since I do have fast internet (gigabit download speed over ethernet). When I applied my event listener change "win.addEventListener("yt-navigate-finish", () => { setResolution(userSettings.targetResolution); });" to your previous version of the script I didn't notice any abnormal delay for the script applying the settings to 1080p non-hdr videos since it just applied the settings for the very first second of the videos (https://www.youtube.com/watch?v=pbvc8_RYKrw). Could you possibly test the script again with the previous version of the code but with my event listener change added in? Since you mentioned that fast internet speed might have an affect on the how the script operates I will understand if you are having issues on your end and if you want to keep the script as if you still keep encountering issues with the previous version of the script with my event listener change thats fine too.
I am also loading YouTube over gigabit ethernet and honestly experienced the opposite issue when testing. Your approach would load 4k videos fine but introduced a delay when loading lower res videos pretty consistently.
The new update pushed today (2024.08.10) essentially incorperates your change to verify that the setting has applied, but keeps the previous implementation to apply settings as early as possible when it works. This should hopefully fix the issues on both fronts at the same time.
One feature that I would like to be added would be the option to set the quality of the video early like the original "Youtube HD" script by adisib which this script is based on. The "Youtube HD" script by adisib was able to set the video of 4k 60 fps videos early so that when you clicked on a 4k 60 fps it would be playing in 4k 60 fps during the very first second of the video. Right now this script usually sets the resolution of 4k 60 fps videos to 4k 60 fps 7 to 10 seconds after the video already started playing. I am not sure if setting the video resolution early is possible anymore but if it is it would be a great option to add to this script.