The legislation required is allowing reverse engineering for interoperability. If there was a legal, alternative Youtube frontend that everyone used and didn't do this crap - YouTube's UI would be forced to compete. As it is, writing such a client/frontend (even if you preserve the ads) will probably land you in legal hot water.
See also: how reddit shut down superior competing UIs by changing their API terms.