// ==UserScript== // @name Crunchyroll Set Default Language // @name:de Crunchyroll Set Default Language // @namespace http://tampermonkey.net/ // @version 0.1 // @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 // @downloadURL none // ==/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() { // 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}`; } } // Perform the check on page load. checkAndRedirect(); })();