iCloud full day events border

Apply the default border with the good color on full day events.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        iCloud full day events border
// @description Apply the default border with the good color on full day events.
// @namespace   https://gitlab.com/breatfr
// @match       https://www.icloud.com/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';

    function applyBorderStyle() {
        const iframes = document.querySelectorAll('iframe');

        iframes.forEach(iframe => {
            try {
                const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
                const buttons = iframeDoc.querySelectorAll('div:not(:has(.month-view-event-preview-start-time)) .css-6310j7 > button:not(:has(svg))');

                buttons.forEach(button => {
                    const computedStyle = getComputedStyle(button);

                // Check if a border is defined with a color
                    if (computedStyle.border && computedStyle.border !== '0px none rgba(0, 0, 0, 0)') {
                        const borderColor = computedStyle.borderColor || computedStyle.borderLeftColor;

                        // If a color is defined, apply the left border
                        if (borderColor && borderColor !== 'rgba(0, 0, 0, 0)') {
                            button.style.borderLeft = `3px solid ${borderColor}`;
                        }
                    }
                });
            } catch (error) {
                console.error('Erreur avec un iframe:', error);
            }
        });
    }

    const observer = new MutationObserver(applyBorderStyle);

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    applyBorderStyle();
    setInterval(applyBorderStyle, 1000);
})();