Lemmy/KBin Redir

Redirects all Lemmy/kbin links to the host of your choice mine being kbin.

Stan na 16-06-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           Lemmy/KBin Redir
// @version        0.2.1
// @author         ikeman2003
// @description    Redirects all Lemmy/kbin links to the host of your choice mine being kbin.
// @match          *://*.lemmy.ml/c/*   
// @match          *://*.lemmynsfw.com/c/*
// @match          *://*.sh.itjust.works/c/*
// @match          *://*.beehaw.org/c/*
// @match          *://*.lemmy.world/c/*
// @match          *://*.midwest.social/c/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=kbin.social
// @run-at         document-start
// @namespace https://greasyfork.org/users/934524
// ==/UserScript==

// Enforce strict mode for better code quality
'use strict';

// Declare current URL as a constant
const currentURL = window.location.href;

// Declare the host URL as a constant
const hostURL = 'https://kbin.social/m/';

// Check if the current URL is leading to lemmy.ml if so, redirect to the host URL
if (currentURL.includes("lemmy.ml/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?lemmy.ml\/c\//, hostURL);
    window.location.replace(newURL + "@lemmy.ml");
} else if (currentURL.includes("https://lemmynsfw.com/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?lemmynsfw\.com\/c\//, hostURL);
    window.location.replace(newURL + "@lemmynsfw.com");
} else if (currentURL.includes("https://sh.itjust.works/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?sh\.itjust\.works\/c\//, hostURL);
    window.location.replace(newURL + "@sh.itjust.works");
} else if (currentURL.includes("https://beehaw.org/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?beehaw\.org\/c\//, hostURL);
    window.location.replace(newURL + "@beehaw.org");
} else if (currentURL.includes("https://lemmy.world/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?lemmy\.world\/c\//, hostURL);
    window.location.replace(newURL + "@lemmy.world");
} else if (currentURL.includes("https://midwest.social/c/")) {
    const newURL = currentURL.replace(/^https?:\/\/(www\.)?midwest\.social\/c\//, hostURL);
    window.location.replace(newURL + "@midwest.social");
}