From fd7d61b291b832301450d1ef65994ee2445772de Mon Sep 17 00:00:00 2001 From: Agampreet Singh <68941022+agam778@users.noreply.github.com> Date: Fri, 9 Aug 2024 19:07:33 +0530 Subject: [PATCH] Remove ad div in Outlook when adblocking is enabled --- app/main.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/app/main.js b/app/main.js index 025455d..3bd1279 100644 --- a/app/main.js +++ b/app/main.js @@ -311,6 +311,39 @@ app.on("web-contents-created", (event, contents) => { } } } + BrowserWindow.getAllWindows().forEach((window) => { + if (window.webContents.getURL().includes("outlook.live.com")) { + window.webContents + .executeJavaScript( + ` + const observer = new MutationObserver((mutationsList) => { + let adElementFound = false; + for (const mutation of mutationsList) { + if (mutation.type === 'childList') { + const adElement = document.querySelector('div.GssDD'); + if (adElement) { + adElement.remove(); + adElementFound = true; + } + } + } + if (adElementFound) { + observer.disconnect(); + } + }); + + observer.observe(document.body, { childList: true, subtree: true }); + + const adElement = document.querySelector('div.GssDD'); + if (adElement) { + adElement.remove(); + observer.disconnect(); + } + ` + ) + .catch(); + } + }); contents.insertCSS( ` ::-webkit-scrollbar {