Redirects Reddit links to privacy friendly Redlib alternative from any webpage.
// ==UserScript== // @name Reddit to Redlib Universal Redirector // @namespace http://tampermonkey.net/ // @version 1.0 // @description Redirects Reddit links to privacy friendly Redlib alternative from any webpage. // @match *://*/* // @run-at document-start // @grant none // @license unlicense // ==/UserScript== (function() { 'use strict'; // Function to redirect Reddit URLs to Libreddit(Redlib) function redirectToLibreddit(url) { return url.replace(/^(https?:\/\/)?(www\.)?reddit\.com/, 'https://libreddit.bus-hit.me'); } // Redirect if we're already on a Reddit page if (/^(www\.)?reddit\.com$/.test(window.location.hostname)) { window.stop(); window.location.replace(redirectToLibreddit(window.location.href)); } // Function to handle link clicks and redirects function handleLinkClick(e) { let target = e.target.closest('a'); if (target) { let url = target.href || target.getAttribute('data-href'); if (url && url.includes('reddit.com')) { e.preventDefault(); window.location.href = redirectToLibreddit(url); } } } // Add event listeners for both click and mousedown events ['click', 'mousedown'].forEach(eventType => { document.addEventListener(eventType, handleLinkClick, true); }); })();