That only works by users crowdsourcing and flagging the advert sections.
By doing it on the fly, each user could get different ads in different places.
You could have an app running in the background that detects ads based on the audio (like Shazam for music) and skips it for you. You could probably analyse all the video slices YT sends you and detect ads that way. I think as long as we are still in control of the playback devices we can find ways to make them skip ads.
Sure, you could do that.
You could also download the stream multiple times under different profiles, compare them and then strip away differences.
But we’re quickly exiting “one guy with a bit of Javascript” territory.
There even is a project that uses machine learning to detect sponsor segments. https://github.com/xenova/sponsorblock-ml
MythTV has a broadcast television ad detection module and it works pretty damn well.
This goes into a bit of detail on it’s methods:
https://www.mythtv.org/wiki/Commercial_detection
A lot of what it does could be applied to a video stream, although adapting it to useful real-time could be tricky.