iCloud full weekday names

Replace abbreviated weekday names with full names based on browser language

ही स्क्रिप्ट इंस्टॉल करा?
लेखकाने सुचवलेली स्क्रिप्ट

तुम्हाला कदाचित ही स्क्रिप्टदेखील आवडेल: iCloud customizations.

युझरस्टाईलच्या रूपात इंस्टॉल करा
// ==UserScript==
// @name        iCloud full weekday names
// @description Replace abbreviated weekday names with full names based on browser language
// @namespace   https://gitlab.com/breatfr
// @match       https://www.icloud.com/applications/calendar/*
// @version     1.0.0
// @homepageURL https://gitlab.com/breatfr/icloud
// @supportURL  https://discord.gg/Q8KSHzdBxs
// @author      BreatFR
// @copyright   2024, BreatFR (https://breat.fr)
// @grant       none
// @icon        https://gitlab.com/uploads/-/system/project/avatar/65415880/icloud.png
// @license     AGPL-3.0-or-later; https://www.gnu.org/licenses/agpl-3.0.txt
// ==/UserScript==

(function() {
    'use strict';

    // Obtenir les abréviations de jours dans la langue du navigateur
    function getAbbreviatedDays() {
        const formatterShort = new Intl.DateTimeFormat(navigator.language, { weekday: 'short' });
        const formatterLong = new Intl.DateTimeFormat(navigator.language, { weekday: 'long' });
        const abbreviatedToFull = {};

        // Créer une correspondance entre les abréviations et les noms complets
        for (let i = 0; i < 7; i++) {
            const date = new Date(Date.UTC(2024, 0, 1 + i)); // Une semaine fictive en janvier 2024
            const shortName = formatterShort.format(date).replace('.', '').trim(); // Supprime les points
            const fullName = formatterLong.format(date).trim();
            abbreviatedToFull[shortName] = fullName;
        }

        return abbreviatedToFull;
    }

    const daysMap = getAbbreviatedDays();

    // Fonction pour remplacer les abréviations
    function replaceDays() {
        const elements = document.querySelectorAll('span.css-1fdlgye, span.css-p0zmmh, div.css-1ttvfef');
        elements.forEach(el => {
            const text = el.textContent.trim().replace('.', ''); // Supprime le point final
            if (daysMap[text]) {
                el.textContent = daysMap[text];
            }
        });
    }

    // Observer pour détecter les modifications dynamiques
    const observer = new MutationObserver(replaceDays);
    observer.observe(document.body, { childList: true, subtree: true });

    // Appliquer la transformation au chargement
    replaceDays();
})();