duckduckgo / tracker-surrogates

💉 Surrogates are small scripts that our apps and extensions serve in place of trackers that cause site breakage when blocked.
Other
20 stars 11 forks source link

Harden the YouTube Iframe API surrogate script further #13

Closed kzar closed 1 year ago

kzar commented 1 year ago

It turns out that some websites use the YouTube Iframe API in a way that's not really documented. I'm not sure why that is, but we should still handle them correctly:

  1. If the video ID isn't specified, it shouldn't be appended to the URL. The URL is broken either way, but some websites seem to later set the correct video ID after the video's load event is fired.
  2. If the target of the new YT.Player() is an iframe element, the element should be reused instead of replaced with an iframe element. Also, parameters set directly in the iframe's src URL (instead of passed in the config Object) should be used.
  3. If the website loads the YouTube Iframe API script after page load has completed, we should at least try to initiate the feature, even if some of the element mapping code-paths can't work. Otherwise, no placeholders are shown.
  4. If the website waits for the onReady event to fire for a video before setting the video ID, we should try to handle that too.