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

< Opinie na Youtube Embed Tweak HTML5 (16 February 2018)

Pytanie/komentarz

woxxomMod
§
Napisano: 25-08-2014

Make it work on dynamically added content

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

jason37Autor
§
Napisano: 29-08-2014
Edytowano: 29-08-2014

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
§
Napisano: 29-08-2014
Edytowano: 29-08-2014

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.

jason37Autor
§
Napisano: 29-08-2014

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
§
Napisano: 29-08-2014

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

woxxomMod
§
Napisano: 27-10-2014
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]);
jason37Autor
§
Napisano: 31-10-2014

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

woxxomMod
§
Napisano: 01-11-2014
Edytowano: 01-11-2014

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);
jason37Autor
§
Napisano: 02-11-2014
Edytowano: 02-11-2014

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

Odpowiedz

Zaloguj się, by odpowiedzieć.