Last active
April 25, 2024 08:48
-
-
Save rztprog/373f3df9ad74242b7bbb8d260e67e5dd to your computer and use it in GitHub Desktop.
[DEPRECATED] Outlook Web Plus - Tampermokey - Remove ads and enhance Outlook web mailbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// | |
// | |
// | |
// THIS ADDON IS DEPRECATED PLEASE USE : https://github.com/rztprog/outlook-web-plus | |
// | |
// | |
// | |
// | |
// ==UserScript== | |
// @name Outlook Web Plus | |
// @namespace http://github.com/rztprog | |
// @version 0.7 | |
// @description Remove ads and enhance Outlook web mailbox | |
// @author Rztprog | |
// @match https://outlook.live.com/* | |
// @icon https://i.imgur.com/VtYtxuD.png | |
// @grant none | |
// ==/UserScript== | |
// THIS ADDON IS DEPRECATED PLEASE USE : https://github.com/rztprog/outlook-web-plus | |
(function() { | |
'use strict'; | |
let timer = null; | |
const greenColor = "#498205"; | |
const cleanSide = () => { | |
const leftBar = document.getElementById("LeftRail"); | |
if (leftBar !== null) { | |
leftBar.style.display = "none"; | |
clearInterval(timer); | |
rootFolder(); | |
cleanMailPub(); | |
cleanPremium(); | |
mailCalculator(); | |
selectAll(); | |
addButtonClickListeners(); | |
cleanTopBar(); | |
} | |
} | |
timer = setInterval(cleanSide, 50); | |
const cleanPremium = () => { | |
const findPremium = () => { | |
const premiumAd = document.querySelector(".Ogqyq"); | |
if (premiumAd) { | |
premiumAd.style.display = "none"; | |
clearInterval(timer2); | |
} | |
} | |
const timer2 = setInterval(findPremium, 50); | |
} | |
const cleanTopBar = () => { | |
const findTopBar = () => { | |
const children = document.getElementById("headerButtonsRegionId").children; | |
if (children.length >= 7) { | |
document.getElementById("owaMeetNowButton").style.display = "none"; | |
document.getElementById("skype_container").style.display = "none"; | |
document.getElementById("owaNoteFeedButton_container").style.display = "none"; | |
clearInterval(timer2); | |
} | |
} | |
const timer2 = setInterval(findTopBar, 50); | |
} | |
const cleanMailPub = () => { | |
let counter = 0; | |
const findTopMail = () => { | |
const topMail = document.querySelector(".cJ3F3"); | |
if (topMail) { | |
topMail.style.display = "none"; | |
clearInterval(timer2); | |
} | |
if (counter > 20) { | |
clearInterval(timer2); | |
} | |
counter++; | |
} | |
const timer2 = setInterval(findTopMail, 50); | |
} | |
const rootFolder = () => { | |
document.querySelector(".wk4Sg").addEventListener("click", function() { | |
cleanMailPub(); | |
}); | |
} | |
const selectAll = () => { | |
// Reload mailCalculator When click on "select all messages" or "select specify message" | |
const findButton = () => { | |
const selectAllButton = document.querySelector('.rk2CU'); | |
const selectMessageButtons = document.querySelectorAll('.d1dnN'); | |
if (selectAllButton && selectMessageButtons) { | |
selectMessageButtons.forEach(button => { | |
button.addEventListener("click", () => { | |
if (button.getAttribute("aria-checked") === "true") { | |
setTimeout(mailCalculator, 100); | |
} | |
}); | |
}); | |
selectAllButton.addEventListener("click", () => { | |
if (selectAllButton.getAttribute("aria-checked") === "true") { | |
setTimeout(mailCalculator, 100); | |
} | |
}); | |
clearInterval(timer2); | |
} | |
} | |
const timer2 = setInterval(findButton, 50); | |
} | |
const mailCalculator = () => { | |
const findFolder = () => { | |
const titleFolder = document.querySelector('.jXaVF'); | |
if (titleFolder) { | |
const titleFolderText = titleFolder.innerText; | |
const firstMail = document.querySelector('.hcptT'); | |
const numberOfEmails = firstMail ? firstMail.getAttribute('aria-setsize') : 0; | |
const regex = /\s\(\d+ mails\)/; | |
// Prevent duplication | |
if (regex.test(titleFolderText)) { | |
titleFolder.innerHTML = titleFolderText.replace(regex, ` <b style="color: ${greenColor}">(${numberOfEmails} mails)</b>`); | |
} else { | |
titleFolder.innerHTML = `${titleFolderText} <b style="color: ${greenColor}">(${numberOfEmails} mails)</b>`; | |
} | |
clearInterval(timer2); | |
} | |
} | |
const timer2 = setInterval(findFolder, 50); | |
} | |
const addButtonClickListeners = () => { | |
const findButtons = () => { | |
const buttons = document.querySelectorAll('.C2IG3'); | |
if (buttons) { | |
buttons.forEach(button => { | |
button.addEventListener('click', () => { | |
setTimeout(selectAll, 100); | |
setTimeout(mailCalculator, 100); | |
}); | |
}); | |
clearInterval(timer2); | |
} | |
} | |
const timer2 = setInterval(findButtons, 50); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment