Greasy Fork is available in English.

Reddit Language Select 🗣️

Automatically select English as language if not already done

질문, 리뷰하거나, 이 스크립트를 신고하세요.
// ==UserScript==
// @name         Reddit Language Select 🗣️
// @namespace    http://your-namespace.com
// @version      1.0
// @description  Automatically select English as language if not already done
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @author       Your Name
// @match        https://*.reddit.com/*
// @exclude      https://*.reddit.com/prefs/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

       // check if language is already set
       function elementContainsText(selector, text) {
            var element = document.querySelector(selector);
            return element && element.textContent.includes(text);
        }

        // Function to change the value and text of the selected option in the language dropdown list
        function changeSelectedOption(selectId, newValue, newText) {
            var selectElement = document.getElementById(selectId);

            // Check if the select element is found
            if (selectElement) {
                // Find the selected option and change its value and text content
                var selectedOption = selectElement.querySelector('option[selected="selected"]');
                // Check if the selected option is found
                if (selectedOption) {
                    selectedOption.value = newValue;
                    selectedOption.textContent = newText;
                }
            }
        }

        // Sequentially click the buttons
        if (!elementContainsText('.pref-lang', 'English') && !elementContainsText('.pref-lang', 'preferences')) {
               document.querySelector('.pref-lang').click();
               setTimeout(function() {changeSelectedOption('lang', 'en', 'English [en]');}, 200);
               setTimeout(function() {document.querySelector('input.btn').click()}, 500);
        }

})();