Guide: Automatically turn Youtube to Invidious, and Twitter to Nitter in Firefox and Chrome

To /r/privacy:

By now I assume most use the HTTPS Everywhere browser extension by the EFF, which directs you to https://site when typing site or http://site. This works by rewriting URLs before your browser attempts to fetch them; HTTPS Everywhere changes the protocol (http --> https) portion of the URL.

However, we can (ab)use this extension to change protocol, domain, path, and query of a URL. We can create rules to transform Twitter to Nitter, and Youtube to Invidious. This means if you click or type a Youtube link, it will automatically be directed to Invidious. Or if you click or type a Twitter page, it will automatically be directed to Nitter.

On Chrome:

  1. about:extensions
  2. Click on Details of HTTPS Everywhere
  3. Click on Extension Options
  4. Click Advanced Settings

On Firefox:

  1. about:addons
  2. Click the ellipsis -> Preferences for HTTPS Everywhere

On both:

  1. Type ctrl+z, a link should magically appear called "Debugging Rulesets (advanced)"
  2. Click that link

(If you dare to type all this in on Firefox for Android, go to about:addons, HTTPS Everywhere, Settings, go to the URL bar and change /pages/options/index.html to /pages/debugging-rulesets/index.html.

Type these rules in:

    <ruleset name="yt2in_nojs">
      <target host="youtube.com" />
      <target host="www.youtube.com" />

      <rule from="^https?://(www\.)?youtube.com/watch\?"
            to="https://invidio.us/watch?nojs=1&amp;" />
    </ruleset>


    <ruleset name="twit2nit">
      <target host="twitter.com" />
      <target host="www.twitter.com" />

      <rule from="^https?://(www\.)?twitter.com/"
            to="https://nitter.net/" />
    </ruleset>

Hit Save, and now these will automatically transform:

Transforming youtu.be/video to invidio.us/watch?v=video is left as an exercise for the reader!

I will point out the disclaimer from HTTPS Everywhere regarding usage of the debugging rulesets:

Warning: This should only be used for debugging rulesets. This feature is not guaranteed to work reliably for regular usage.

This is a (silent) hack and not how HTTPS Everywhere is intended to be used; you will ultimately forget that you did this and scratch your head why web sites are going to other sites. You have been warned.