// ==UserScript==
// @name        URL conversion | yt -> invidious
// @namespace   https://localhost/
// @description simple regex based twitter to invidious redirection snippet
// @match       *://twitter.com/*
// @version     1
// @run-at      document-start
// @grant       none
// ==/UserScript==

(function fucktwitter() {
    var url = window.location.toString();

    var findanddestroy = function (url) {
        if (url.indexOf('twitter.com') !== -1)
            return true;

        return false;
    }

    if (findanddestroy(url)) {
        //var regex = /(?:\/.*\/)(.*)/;
        var regex = /(https?:\/\/)([^:^\/]*)(:\\d*)?(.*)?/;
        var payload = regex.exec(url)[4];
        var redirect = ('https://nitter.eu/' + payload.substring(1));
        unsafeWindow.window.location.replace(redirect);
    }
})();
