Greasy Fork is available in English.
Replace abbreviated weekday names with full names based on browser language
当前为
// ==UserScript==
// @name iCloud 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://www.icloud.com/system/icloud.com/2426Hotfix51/721bdfc3241b42114d62842854461ae7.png
// @license BY-NC-ND; https://creativecommons.org/licenses/by-nc-nd/4.0/
// ==/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();
})();