Cacher Annonces sur Gmail

Cache les lignes contenant 'Annonce' dans les spans sur Gmail

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Cacher Annonces sur Gmail
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Cache les lignes contenant 'Annonce' dans les spans sur Gmail
// @author       Gann
// @match        https://mail.google.com/*
// @grant        none
// @license MIT
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // Fonction pour vérifier et cacher les rows
    function hideAnnonceRows() {
        const rows = document.querySelectorAll('tr');
        rows.forEach(row => {
            const spans = row.querySelectorAll('span');
            spans.forEach(span => {
                if (span.textContent.includes("Annonce")) {
                    row.style.display = 'none';
                }
            });
        });
    }

    // Exécute la fonction après que le DOM soit entièrement chargé
    window.addEventListener('load', hideAnnonceRows);

    // Pour Gmail, qui charge les contenus dynamiquement, on utilise une observation sur le body
    const observer = new MutationObserver(hideAnnonceRows);
    observer.observe(document.body, { childList: true, subtree: true });
})();