janoyolo / Remove outlook Addbar & Promobar

// ==UserScript==
// @name         Remove outlook Addbar & Promobar
// @version      0.2
// @description  Remove outlook Addbar & Promobar
// @author       Jean
// @require      https://code.jquery.com/jquery-3.5.1.min.js
// @include      https://outlook.live.com/*
// @grant		 none
// @license      MIT
// ==/UserScript==

(function() {
    // Your code here...

    function hideBar(path, label, fn) {
        let $bar = $(path)
        if ($bar.is(':visible')) {
            console.log(label + ' Visible: Hide & stop script')
            $bar.css("display","none")
        } else {
            // console.log(label + ' not Visible: continue script')
            setTimeout(fn, 1000)
        }
    }

    function hideAddBar(){
        hideBar($("#app div[role=region]").next().next().next(), 'AddBar', hideAddBar)
    }

    function hidePromoBar(){
        hideBar($("#app div[role=region] div[role=menubar]:eq(0)").prev(':not(.ms-FocusZone)'), 'PromoBar', hidePromoBar)
    }

    $(document).ready(function(){
        console.log('Start AddBar script')
        hideAddBar()
        console.log('Start PromoBar script')
        hidePromoBar()
    });
})();