invidio_proxy_mode.user.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // ==UserScript==
  2. // @name Invidious - Proxy Mode
  3. // @version 0.1.9
  4. // @author Jesús E.
  5. // @license GPL version 3 or any later version::: https://www.gnu.org/licenses/gpl-3.0.html
  6. // @description This script automatically Proxy-Mode on Invidious and its various public instances.
  7. // @namespace InvidiousProxy
  8. // @homepageURL https://git.sr.ht/~heckyel/book/blob/master/scripts-greasemonkey
  9. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidio[.]us)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  10. // @include /(?:(?:http(s|):\/\/)(www[.]|proxy[.]|)(?:invidious[.]snopyta[.]org)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  11. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:vid[.]wxzm[.]sx)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  12. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidious[.]kabi[.]tk)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  13. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidiou[.]sh)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  14. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:yewtu[.]be)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  15. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidious[.]ggc-project[.]de)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  16. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidious[.]enkirton[.]net)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  17. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:tube[.]poal[.]co)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  18. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidious[.]13ad[.]de)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  19. // @include /(?:(?:http(s|):\/\/)(www[.]|)(?:invidious[.]drycat[.]fr)\/(watch\?v=|embed\/))([^= &?(\/)\r\n]{8,11})(\S+)?$/
  20. // @grant none
  21. // ==/UserScript==
  22. function proxyMode() {
  23. const consoleCSS = 'background: #000; color: #00FF00; padding: 0px 7px; border: 1px solid #00FF00; line-height: 16px;';
  24. const name = GM_info.script.name;
  25. const version = GM_info.script.version;
  26. const log = (...args) => console.log('%cUSERSCRIPT | %s %s | %s', consoleCSS, name, version, ...args);
  27. // Set variables
  28. let i, j, url;
  29. let vids_tags = ["video", "source"];
  30. let vids_elements, proxyURL;
  31. // Regex
  32. let params=new RegExp(/itag=(18|22|43)$/);
  33. for (i = 0; i < vids_tags.length; i++) {
  34. vids_elements = document.getElementsByTagName(vids_tags[i]);
  35. for (j = 0; j < vids_elements.length; j++) {
  36. url = vids_elements.item(j).src;
  37. if(params.test(url)) {
  38. proxyURL = url + "&local=true";
  39. vids_elements.item(j).src = proxyURL;
  40. } else {
  41. console.log('Proxy was already applied or Live URL');
  42. }
  43. }
  44. }
  45. log('successfully initialized');
  46. }
  47. proxyMode();
  48. // Fix Abrowser
  49. window.addEventListener('load', () => {
  50. proxyMode();
  51. });