Reddit to Libreddit

Converts Reddit links to Libreddit links

目前為 2023-07-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Reddit to Libreddit
// @namespace    happyviking
// @version      1.0
// @description  Converts Reddit links to Libreddit links
// @author       HappyViking
// @match        *://*.reddit.com/*
// @icon         https://www.google.com/s2/favicons?domain=www.reddit.com
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==


// Heavy credit to:
// https://gf.qytechs.cn/en/scripts/432711-libreddit-converter/code
// https://gf.qytechs.cn/en/scripts/465089-libreddit-redirector/code


function isProperTargetPage(url) {
    return !!url.match(/^(|http(s?):\/\/)(.*\.)?reddit.com(\/.*|$)/gim);
}

function getNewUrl(url) {
    return 'https://farside.link/libreddit' + url.split('reddit.com').pop();
}

if (isProperTargetPage(window.location.href)) {
    const newUrl = getNewUrl(window.location.href)
    location.replace(newUrl);
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址