Greasy Fork is available in English.

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)についてのフィードバック

質問/コメント

woxxomMod
§
投稿日: 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.

woxxomMod
§
投稿日: 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.

woxxomMod
§
投稿日: 2014/08/29

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

woxxomMod
§
投稿日: 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.

woxxomMod
§
投稿日: 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.

返信を投稿

返信を投稿するにはログインしてください。