Youtube Embed Tweak HTML5 (16 February 2018)

Forces all emdedded Youtube videos to the new player. With options for: Video size, https, hide annotations and hide related and hide controls

< 脚本Youtube Embed Tweak HTML5 (16 February 2018)的反馈

提问/评论

woxxom管理员
§
发表于:2014-08-25

Make it work on dynamically added content

Currently the script doesn't work on content loaded dynamically - for example on sites with endless scroll.

jason37作者
§
发表于:2014-08-29
编辑于:2014-08-29

Do you have an example url? I have been considering trying to make it work on google+ but the site already has varied video size and it would mess with the layout of the page.

woxxom管理员
§
发表于:2014-08-29
编辑于:2014-08-29

Click the bluish Comments icon under the first post here (KIESZA - HIDEAWAY COVER video), the new content will be injected into the page with a few embedded youtube videos in it.

jason37作者
§
发表于:2014-08-29

Ok I see. This is because the script is executed on every page load. I am not sure how to get it to execute on that content, i think i may need an additional option to reexecute the script after the comments have been loaded. I will look in to how this can be done.

woxxom管理员
§
发表于:2014-08-29

A mutation observer might do the trick, works in Chrome too, doesn't slow down browsing experience.

woxxom管理员
§
发表于:2014-10-27
var ob = new MutationObserver(function(mutations){
  for (var m, i=0; i<mutations.length && (m=mutations[i]); i++)
    for (var nodes=m.addedNodes, n, j=0; j<nodes.length && (n=nodes[j]); j++)
      embedTweak(n);
});
ob.observe(document, {subtree:true, childList:true});

if (document.body)
  embedTweak(document.body);

function embedTweak(node) {
..........
your code
..........
}

Note that the first document should be replaced with node:

    risky_elements = node.getElementsByTagName(risky_tags[i]);
jason37作者
§
发表于:2014-10-31

Thanks. That works great. I have added to the script and updated it.

woxxom管理员
§
发表于:2014-11-01
编辑于:2014-11-01

I just found a relatively popular site that dumbly modifies the text of an element with current time almost 100 times per second so the mutation observer is called every time only to fail on node.getElementsByTagName overfilling the js console with error messages, here's a fix:

    for (var nodes=m.addedNodes, n, j=0; j<nodes.length && (n=nodes[j]); j++)
      if (n.nodeType == Node.ELEMENT_NODE)
        embedTweak(n);
jason37作者
§
发表于:2014-11-02
编辑于:2014-11-02

I noticed the errors in the console but it still worked, so thought it was just a warning. Thanks for fix.

发表回复

登录(不可用)以发表回复。

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址