YouTube Player for TKG

Автомат. замена ссылок вида youtu.be на плеер для TorrentPier / Thanks yup from forum.mozilla-russia.org

  1. // ==UserScript==
  2. // @name YouTube Player for TKG
  3. // @namespace www.torrent.kg
  4. // @description Автомат. замена ссылок вида youtu.be на плеер для TorrentPier / Thanks yup from forum.mozilla-russia.org
  5. // @include http://www.torrent.kg/forum/*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9. //document.body.innerHTML= document.body.innerHTML.replace(/111/g,"222");
  10. var player, i, link, links = document.getElementsByClassName("postLink");
  11. for (i = links.length-1; i >= 0; i--) {
  12. link = links[i];
  13. if ((link.nodename == "A") || (link.hostname == "youtu.be")) {
  14. player = document.createElement("iframe");
  15. player.src = "https://www.youtube.com/embed" + link.pathname + "?ecver=2";
  16. player.width = 640;
  17. player.height = 360;
  18. player.frameBorder = 0;
  19. player.allowFullscreen = true;
  20. link.parentElement.replaceChild(player, link);
  21. }
  22. }