Greasy Fork is available in English.

Outlook.com Ad Remover

Remove ads from Outlook.com mail interface

// ==UserScript==
// @name         Outlook.com Ad Remover
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Remove ads from Outlook.com mail interface
// @author       aspen138
// @match        *://outlook.live.com/mail/0/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to remove ad elements
    function removeAds() {
        // Remove elements with aria-label="广告" (Ad in Chinese)
        document.querySelectorAll('[aria-label="广告"]').forEach(el => {
            el.closest('div[class]').remove();
        });

        // Remove elements with ID starting with 'owaadbar'
        document.querySelectorAll('[id^="owaadbar"]').forEach(el => {
            el.closest('div[class]').remove();
        });

        // Remove ad placeholders or related elements if any
        document.querySelectorAll('.VdboX, .GssDD, .z0duZ').forEach(el => {
            el.remove();
        });
    }

    // Run on page load
    window.addEventListener('load', removeAds);

    // Observe mutations to handle dynamic content (SPA behavior)
    const observer = new MutationObserver(removeAds);
    observer.observe(document.body, { childList: true, subtree: true });
})();