Closed dnet890 closed 1 year ago
Here's a quick userscript that does that:
// ==UserScript==
// @name Redirect Reddit Links to Troddit
// @namespace Reddit Scripts
// @description Attempts to redirect all clicks on Reddit URLs to Troddit.
// Known bug: Fails if navigation is done with JS instead of pure HTML (ie New Reddit feed).
// @match <all_urls>
// @version 1.0
// @grant none
// ==/UserScript==
document.body.addEventListener('click', e => {
// in case target is a tag inside a link, ie DDG results are `span`s inside `a`s
const tag = e.target.closest('a');
const reddit = /https?:\/\/(\w+\.)?reddit\.com\//;
const troddit = 'https://troddit.com/';
if (tag?.href?.match(reddit)) {
tag.href = tag.href.replace(reddit, troddit);
}
});
Not sure if there's a better way or not, but this is simple at least.
You could use Libreddirect extension for it. Also supports other sites like Twitter, Youtube and more.
Adding https://www.troddit.com as a reddit instance in the Libreddirect extension works so no need for a custom extension.
Hi if we google search reddit url, it will be really wonderful if this url automatically changed to troddit URL like wikiwand with their browser extension and it is also beneficial to promote this project further. What do you think?