points by bmacho 3 years ago

Or for people that are allergic to random browser extensions :

    // ==UserScript==
    // @name         twitter redirect
    // @namespace    -
    // @version      -
    // @description  redirects twitter to nitter
    // @author       -

    // @noframes

    // @match        http://twitter.com/*
    // @match        https://twitter.com/*
    // @match        http://*.twitter.com/*
    // @match        https://*.twitter.com/*

    // @exclude      http://platform.twitter.com/*
    // @exclude      https://platform.twitter.com/*

    // @grant        none
    // @run-at       document-start
    // ==/UserScript==


    var nitterInstance = "https://nitter.net"

    if (window.top != window.self) { //don't run in frames or iframes
        return;
    }

    const loc = window.location

    const path = loc.pathname
    const host = loc.host
    const href = loc.href

    console.info( "host:", host, "\npath:", path, "\nhref:", href );

    let redirectTo = ""

    if ( host == "twitter.com" || host.endsWith(".twitter.com") ) {
        redirectTo = `${nitterInstance}${path}`
        doRedirect()
    }

    function doRedirect() {

        console.info( `==> RedirectTo ${ redirectTo }` )
        window.location.assign( redirectTo )

    }

It is extensible.

Maybe I should group the site specific data together, so one could add/remove new sites at one place instead of several (two?) different places.

Also checking against a ?noredirect or something in the URL sound like a feature I could use.

falcor84 3 years ago

That's too long, could you please instead give me a GPT prompt that would generate that? /s