Youtube to Invidio.us Embed

Forces all embedded Youtube videos to Invidio.us for watch youtube videos with more privacy

  1. // ==UserScript==
  2. // @name Youtube to Invidio.us Embed
  3. // @description Forces all embedded Youtube videos to Invidio.us for watch youtube videos with more privacy
  4. // @version 1.2
  5. // @include http*
  6. // @exclude *youtube.com/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/433508
  9. // ==/UserScript==
  10.  
  11. // Domain of Invidio instance, change by your prefer (Default: invidio.us)
  12. var invidioUrl = 'invidio.us';
  13.  
  14. function noYt() {
  15. var i, attr, index, video, tag = document.getElementsByTagName('iframe');
  16. for (i = 0; i < tag.length; i++) {
  17. attr = tag[i].getAttribute('src');
  18. index = 0;
  19. if (attr.indexOf('youtube.com') !== -1) {
  20. if (attr.indexOf('/v/') >= 0) {
  21. index = attr.indexOf('/v/') + 3;
  22. } else if(attr.indexOf('?v=') >= 0) {
  23. index = attr.indexOf('?v=') + 3;
  24. } else if (attr.indexOf('/embed/') >= 0) {
  25. index = attr.indexOf('/embed/') + 7;
  26. }
  27. video = attr.substring(index, index + 11);
  28. }
  29. if (index > 0) {
  30. tag[i].setAttribute('src', 'https://' + invidioUrl + '/embed/' + video);
  31. tag[i].setAttribute('style', 'min-height:100%; min-width:100%;');
  32. tag[i].setAttribute('frameborder', '0');
  33. tag[i].setAttribute('allowfullscreen', '1');
  34. }
  35. }
  36. }
  37.  
  38. noYt();