mirror of
https://github.com/agam778/MS-365-Electron.git
synced 2026-02-17 09:02:10 +00:00
Remove ad div in Outlook when adblocking is enabled
This commit is contained in:
33
app/main.js
33
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 {
|
||||
|
||||
Reference in New Issue
Block a user