Greasy Fork 支持简体中文。

YouTube To Invidious Button

Adds a button to redirect from YouTube to an Invidious instance

  1. // ==UserScript==
  2. // @name YouTube To Invidious Button
  3. // @version 1.0
  4. // @description Adds a button to redirect from YouTube to an Invidious instance
  5. // @author Rust1667
  6. // @match *://www.youtube.com/*
  7. // @namespace https://greasyfork.org/users/980489
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12.  
  13. const invInstances = [
  14. 'redirect.invidious.io',
  15. 'inv.nadeko.net',
  16. 'invidious.nerdvpn.de',
  17. 'invidious.privacyredirect.com',
  18. 'invidious.jing.rocks',
  19. ];
  20. const invInstance = invInstances[Math.floor(Math.random() * invInstances.length)];
  21.  
  22. var button = document.createElement('button');
  23. button.innerHTML = 'Redirect to Invidious';
  24. button.style.position = 'fixed';
  25. button.style.top = '10px';
  26. button.style.right = '300px';
  27. button.style.zIndex = '10000';
  28. button.style.padding = '10px';
  29. button.style.backgroundColor = '#ff0000';
  30. button.style.color = '#ffffff';
  31. button.style.border = 'none';
  32. button.style.borderRadius = '5px';
  33. button.style.cursor = 'pointer';
  34. document.body.appendChild(button);
  35.  
  36. button.onclick = function () {
  37. window.location.assign(window.location.toString().replace('www.youtube.com', invInstance));
  38. };
  39.  
  40. })();