Nitter Instance Switcher

Adds a link with a random public Nitter alternative to easily switch Nitter instances.

  1. // ==UserScript==
  2. // @name Nitter Instance Switcher
  3. // @namespace Violentmonkey Scripts
  4. // @match https://nitter.snopyta.org/*
  5. // @match https://nitter.net/*
  6. // @match https://nitter.13ad.de/*
  7. // @match https://nitter.kavin.rocks/*
  8. // @match https://nitter.cc/*
  9. // @match https://nitter.eu/*
  10. // @grant none
  11. // @version 1.0
  12. // @author BErnd14
  13. // @description Adds a link with a random public Nitter alternative to easily switch Nitter instances.
  14. // ==/UserScript==
  15.  
  16. var instances = ["https://nitter.snopyta.org",
  17. "https://nitter.net",
  18. "https://nitter.13ad.de",
  19. "https://nitter.kavin.rocks",
  20. "https://nitter.cc",
  21. "https://nitter.eu"];
  22.  
  23.  
  24. function shuffleArray(array) {
  25. for (let i = array.length - 1; i > 0; i--) {
  26. const j = Math.floor(Math.random() * (i + 1));
  27. [array[i], array[j]] = [array[j], array[i]];
  28. }
  29. }
  30.  
  31.  
  32. function getIndex(array) {
  33. for (var i = 0; i < instances.length; i++) {
  34. if (window.location.href.includes(instances[i])) {
  35. return i;
  36. }
  37. }
  38. return 0;
  39. }
  40.  
  41.  
  42. shuffleArray(instances);
  43.  
  44. var found_at_index = getIndex(instances);
  45. var next_instance = (found_at_index + 1) % instances.length;
  46. var instance_switch = document.createElement("a");
  47. instance_switch.setAttribute('href', instances[next_instance] + window.location.pathname + window.location.search);
  48. instance_switch.innerHTML = "Next instance (" + instances[next_instance] + ")";
  49. document.getElementsByTagName("nav")[0].prepend(instance_switch);
  50.  
  51.