Greasy Fork

Greasy Fork is available in English.

Crunchyroll Set Default Language

Select default language for Crunchyroll and always redirect to the correct language. Useful if you click on Crunchyroll links other than your language.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Crunchyroll Set Default Language
// @name:de         Crunchyroll Set Default Language
// @namespace       http://tampermonkey.net/
// @version         0.1.4
// @description     Select default language for Crunchyroll and always redirect to the correct language. Useful if you click on Crunchyroll links other than your language.
// @description:de  Wähle die Standardsprache für Crunchyroll aus, um die Seite immer auf die richtige Sprache umzuleiten. Nützlich, wenn auf Crunchyroll-Links in einer anderen als der Standardsprache geklickt werden.
// @author          Lolen10
// @match           https://www.crunchyroll.com/*
// @grant           none
// @license         GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // User-configuration
    // Change this variable according to the desired language name
    // All options are listed below
    const selectedLanguage = 'german';

    // -------------------Normally no changes need to be made below this line--------------------

    // Language codes for various options
    const languageCodes = {
        german: '/de',
        english: '',
        arabic: '/ar',
        spanish: '/es',
        spanishSpain: '/es-es',
        french: '/fr',
        italian: '/it',
        portugueseBrazil: '/pt-br',
        portuguesePortugal: '/pt-pt',
        russian: '/ru',
        hindi: '/hi'
    };

    // Function to check and redirect
    function checkAndRedirect() {
        if (selectedLanguage !== 'english') {
          // Check if the selected language is present in the URL
          if (!window.location.href.includes(languageCodes[selectedLanguage])) {
              // Extract the path and remove any incorrect language code
              let path = window.location.pathname.replace(/\/[a-z]{2}(-[a-z]{2})?(?=\/|$)/, '');
              window.location.href = `https://www.crunchyroll.com${languageCodes[selectedLanguage]}${path}`;
          }
        }else{
          // For english: Check if there is a language code in the URL. If yes: remove it, if no: skip it.
          if (window.location.pathname.match(/\/[a-z]{2}(-[a-z]{2})?(?=\/|$)/)) {
              let path = window.location.pathname.replace(/\/[a-z]{2}(-[a-z]{2})?(?=\/|$)/, '');
              window.location.href = `https://www.crunchyroll.com${path}`;
          }
        }
    }

    // Perform the check on page load.
    checkAndRedirect();

})();