Reddit to Redlib Redirector

Redirects Reddit URLs to Redlib via farside.link

目前為 2025-02-19 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Reddit to Redlib Redirector
// @namespace   https://farside.link/
// @version     1.0
// @description Redirects Reddit URLs to Redlib via farside.link
// @author      Faisal Bhuiyan
// @match       *://*.reddit.com/*
// @grant       none
// @run-at      document-start
// ==/UserScript==

(function() {
    'use strict';

    // Get current URL
    const currentUrl = window.location.href;
    
    // Define Reddit regex pattern
    const Redlib = /reddit.com(\/?.*)/;
    
    // Test if current URL matches Reddit pattern
    if (Redlib.test(currentUrl) === true) {
        // Extract the path part from the URL
        const path = Redlib.exec(currentUrl)[1];
        
        // Redirect to Redlib via farside.link
        window.location.replace('https://farside.link/redlib' + path);
    }
})();