I have been thinking for a while about creating a script that when I am using YouTube, can tell when YouTube is pausing under the pretense that it's buffering and even shows the circular loading thing on the screen, all just because I want to play the video at a faster speed than 1x. For The Mighty Jingles, I can't watch at a rate any faster than 1.25 without this fake buffer happening about every twenty or thirty seconds or something like that. For Linus Tech Tips I can't watch faster than I think 1.5x without fake buffering happening about every five or ten seconds. For Ryan Hall Y'all, you can watch his live storm coverage videos at 2x, but his cohort, Andy, for some reason you can't watch his on 2x without the fake buffer happening.
But in this case, all you have to do is either press skip forward 5 seconds and back again immediately or back five and forward five immediately and it will resume playback at your desired speed. No buffer for another several seconds. And it does it at such a predictable rate most of the time that you can tell this is not a real buffer issue. If I can skip to any other point even one second later or near the end of the video and playback resumes without any trouble, and when it stops playing it shows the circular buffer indicator, then this is just a mechanism intentionally making it look like a buffer.
I was going to write a script to do this but under the weight of other priorities, it fell between the cracks. It would have required a lot of extra testing and stuff because I am not aware of fixes already on the internet for this. I wanted to write a script that could tell the video was buffering and automatically skip forward and back again or whatever so I don't have to tend to it constantly myself and waste more time and effort just to do something that should be easy-going.
But I realized Chrome had a couple of YouTube extensions that optimize it, so it has buttons or plays a certain way or whatever, adopts some behavior that the website itself does not already enable. I accidentally came across a JavaScript window in Enhancer for YouTube where you can insert any JavaScript code you want to tailor your experience the way you want for YouTube. I wish this was a thing with every service, just install a corresponding extension and here is a window to run your own JavaScript code so it runs client-side the way you want the service to run.
This is why we are using JavaScript I assume, because it runs client-side. This is less common these days but everything on the internet used to have to run client side and now I think most of the time if I am not mistaken, most website functionality is handled webserver-side. Including games. Like you process graphics and stuff, but the gameplay is handled server-side I think. But there are benefits to running things client-side, and this is one of them. Hence, why I wish you could just install an extension that works for this service or that one, and the JavaScript window lets yo manipulate it any way you choose to fit your preferences especially if it is client-side.
So I had already installed Enhancer for YouTube a few months back to deal with the resolution issue where YouTube automatically throttles back your resolution anytime the wind blows, and the extension didn't fix it. But I still liked features it offered so I kept it. Then I downloaded another extension called Improve YouTube which does maintain resolution, and I was about to get rid of Enhancer for YouTube when I discovered the JavaScript window and changed my mind. I immediately added code into it to act whenever a fake buffer happens. And I tested it for the first time a few days later. It isn't perfectly clean, sometimes it takes five seconds to respond, but the end result is the same, I don't have to touch it and the video keeps playing at least most of the time. The JavaScript code I entered was this:
let video = document.querySelector('video');
if (video && video.paused && !video.ended) {
video.currentTime -= 5; // Skip back 5 seconds
video.currentTime += 5; // Skip forward 5 seconds
}
}, 3000); // Check every 3 seconds
Just know if you use this the indentation does matter, the first and last lines are not indented, the second and third and sixth lines are indented further and the fourth and fifth is indented the farthest. I just add extra indentation to everything here so the code is clearly separate from my comments. Maybe I should comment out all my comments! Okay so, again, this wasn't played with too much, I just wrote it real quick and inserted it and didn't even have time to play with it. I only tested it a few days later. And it appears to work better than I expected. I am not a coding genius and expect my code to not work at least on the first several times out. But this appears to work on the first try even if it's not clean. If I had to change something, I would try to see if there was a way to optimize it so it acts faster or reacts at the same speed every time but these are things I don't even know if they can be affected by changing the code. I am just really happy at this time that it did work!
Download the extension in Chrome and once in the extension control panel or whatever they call it, click CUSTOM SCRIPT > and enter the code in the window. Be sure you know what any code you enter into this window does because it could potentially compromise your security or something like that.
This has been Truncat3d 00000000111100010100110______________end of line
No comments:
Post a Comment