This script tells YouTube that your browser only supports 30FPS or less, which means that you will see regular 30FPS versions of all HD videos.
For my six year old laptop, switching from 1080p60 to 1080p30 reduces the CPU usage by 2-4x, and removes all CPU overloads that used to make my browser and video playback freeze! This means longer battery life, and a much happier video watching experience!
(Furthermore, most older graphics cards only support hardware acceleration of 1080p30 or lower, which means that using this script may allow your graphics card to perform the video decoding for great battery savings!)
Install the Tampermonkey (https://tampermonkey.net) extension for your specific browser, and then install this script into Tampermonkey.
This script has been tested and confirmed working in Tampermonkey for Safari 9/10/11+ for Mac and Google Chrome for Mac. But it should work in all browsers and OS's that support the Tampermonkey extension - on Windows, Mac and Linux!
However, I only officially guarantee that it works in Chrome and Safari via Tampermonkey!
(This script does NOT work via Chrome's or any similar browser's own basic built-in script support!)
Note about Other Web Browsers: This script absolutely requires a good web browser and a good userscript manager (Tampermonkey!), which is capable of injecting and running this script very early during the YouTube webpage's loading process, so that your browser is able to run my code early enough to block the high-FPS formats before YouTube has already enabled high-FPS playback! I cannot guarantee that all browsers are good enough to run this script! A red warning bar will be displayed at the bottom of the page if your browser fails to disable high-FPS playback in a YouTube tab. There's nothing I can do to fix a bad web browser that is bad at running the code early enough! However, I have personally seen success with Tampermonkey in Chrome, Safari, Firefox and Opera.
Note about Greasemonkey & Violentmonkey: I can only guarantee that Tampermonkey (the best userscript manager) works properly. Some users have had serious problems caused by Greasemonkey (bad) and Violentmonkey (worst), because those are both extremely bad at injecting/running userscripts early enough (see research here for proof of how bad they are). So if you insist on running this script in an "officially unsupported" browser, at least do yourself a favor and install the Tampermonkey extension to maximize your chances of success. ;-)
We DO NOT affect embedded YouTube videos, because embedded players only check for high-FPS support, so blocking those queries would mean completely losing all HD resolutions for embedded videos!
I suggest clicking the "Watch on YouTube" button to play embedded high-FPS videos directly on YouTube in 30FPS instead!
Totally optional. ;-)
Now limits the maximum amount of injection (high-FPS blocking) retries to just two page reloads, and then displays a message bar which lets the user decide what to do if they've all failed. This is just for severely bugged web browsers, since most browsers always succeed on their first attempt!
Minor change to the address bar history handling.
Rewrote the "injection success?" detection method. Previously, we checked for the existence of YouTube's "window.ytplayer" object as a sign of too-late injection. But in Sept of 2017, they rewrote their site so that the object almost always exists by the time our userscript runs. Therefore, the method has instead been changed to now wait for a fraction of a second and then check if our code has actually blocked any formats. If so, we're sure that we've successfully injected the format blocker and disabled high-FPS!
As I've said above, I only officially support Chrome and Safari (because it's a lot of work to test different browsers). However, this new release improves the script's behavior in other browsers, at least for now. The script has been improved and verified to now also work in Firefox with Tampermonkey. But please be aware that Chrome and Safari remain the only officially supported browsers that I will test each release in. Feel free to report any problems you may discover in non-supported browsers, but please don't leave negative reviews regarding those other browsers since I only guarantee Chrome and Safari to work!
After some careful research, I've come up with an even more reliable and faster method for detecting injection success. It now uses a hybrid method, which first does a brand new, instant check that sees if YouTube's video player code has been loaded. If their player has already been loaded, then we treat that as an instant failure and perform a retry. But if there is no player yet, then we can be almost certain that we've successfully been injected into the page early enough. Then, we simply wait a while and perform a final verification (same as in v1.5+ but with a much longer delay) to confirm that we've actually blocked all high-FPS formats. This new method greatly enhances the chances of early success in all browsers. Enjoy!
Enhanced processing speed for the injection-counter in your browser's address bar.
Just a little bit of autumn cleaning (after all these recent changes), to improve the source code readability.