Nitter Instance Switcher

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Nitter Instance Switcher
// @namespace   Violentmonkey Scripts
// @match       https://nitter.snopyta.org/*
// @match       https://nitter.net/*
// @match       https://nitter.13ad.de/*
// @match       https://nitter.kavin.rocks/*
// @match       https://nitter.cc/*
// @match       https://nitter.eu/*
// @grant       none
// @version     1.0
// @author      BErnd14
// @description Adds a link with a random public Nitter alternative to easily switch Nitter instances.
// ==/UserScript==

var instances = ["https://nitter.snopyta.org", 
                 "https://nitter.net",
                 "https://nitter.13ad.de",
                 "https://nitter.kavin.rocks",
                 "https://nitter.cc",
                 "https://nitter.eu"]; 


function shuffleArray(array) {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }
}


function getIndex(array) {
  for (var i = 0; i < instances.length; i++) {
    if (window.location.href.includes(instances[i])) {
      return i;
    }
  }
  return 0;
}


shuffleArray(instances);

var found_at_index = getIndex(instances);
var next_instance = (found_at_index + 1) % instances.length;
  
var instance_switch = document.createElement("a");
instance_switch.setAttribute('href', instances[next_instance] + window.location.pathname + window.location.search);
instance_switch.innerHTML = "Next instance (" + instances[next_instance] + ")";
document.getElementsByTagName("nav")[0].prepend(instance_switch);