From 5d5682d387fa0ee09af470dc423d2c14abc224b2 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Tue, 22 Nov 2022 14:50:08 +0100 Subject: [PATCH] Add nitterify userscript --- userscripts/nitterify.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 userscripts/nitterify.js diff --git a/userscripts/nitterify.js b/userscripts/nitterify.js new file mode 100644 index 0000000..ed4e42d --- /dev/null +++ b/userscripts/nitterify.js @@ -0,0 +1,29 @@ +// ==UserScript== +// @name Nitterify +// @namespace * +// @version 0.1 +// @description Redirect twitter.com links to nitter.net +// @author DarkWiiPlayer +// @match https://*/* +// @icon https://nitter.net/favicon.ico +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + const nitterify = element => { + element + .querySelectorAll('a[href^="https://twitter.com"]') + .forEach(link => { link.href = link.href.replace("twitter.com", "nitter.net") }) + } + + const observer = new MutationObserver(list => { + list.forEach(mutation => { + mutation.addedNodes.forEach(nitterify) + }) + }) + + nitterify(document) + observer.observe(document, { childList: true, subtree: true }) +})();