Last active
November 24, 2023 09:18
-
-
Save garrytrinder/5395720c3adfd945ffc0177146c6a87d to your computer and use it in GitHub Desktop.
Remove personal apps from Outlook web
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
(async (window) => { | |
const ootbApps = [ | |
"Bookings", | |
"Files", | |
"Go to Excel", | |
"Go to OneNote", | |
"Go to PowerPoint", | |
"Go to Word", | |
"SurveyMonkey: Surveys for Feedback", | |
"Viva Engage" | |
]; | |
const removedApps = []; | |
// open app flyout | |
document.querySelector('[data-tid="appbar-flyout-button"]').click(); | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
const apps = []; | |
// get all the apps in the flyout | |
document.querySelectorAll('.fui-PopoverSurface .fui-Button') | |
.forEach(x => { | |
if (x.hasAttribute('id')) apps.push({ el: x, id: x.id, name: x.ariaLabel }) | |
}); | |
// get the first app that is not an ootb app and not already removed | |
let nextApp = apps.find(x => !ootbApps.includes(x.name) && !removedApps.includes(x.name)); | |
while (nextApp) { | |
console.log(`Uninstalling ${nextApp.name}...`); | |
nextApp.el.dispatchEvent( | |
new MouseEvent('contextmenu', { | |
bubbles: true, | |
cancelable: true, | |
view: window, | |
button: 2, | |
buttons: 2, | |
})); | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
document.querySelectorAll('.fui-MenuPopover .fui-MenuItem')[3].click(); | |
await new Promise(resolve => setTimeout(resolve, 1000)); | |
document.querySelectorAll('.ms-Dialog-action button')[1].click(); | |
await new Promise(resolve => setTimeout(resolve, 3000)); | |
document.querySelector('.ms-Dialog-action button').click(); | |
await new Promise(resolve => setTimeout(resolve, 2000)); | |
removedApps.push(nextApp.name); | |
console.log(`Uninstalled ${nextApp.name}`); | |
// open app flyout | |
document.querySelector('[data-tid="appbar-flyout-button"]').click(); | |
await new Promise(resolve => setTimeout(resolve, 2000)); | |
const apps = []; | |
// get all the apps in the flyout | |
document.querySelectorAll('.fui-PopoverSurface .fui-Button') | |
.forEach(x => { | |
if (x.hasAttribute('id')) apps.push({ el: x, id: x.id, name: x.ariaLabel }) | |
}); | |
// get the first app that is not an ootb app and not already removed | |
nextApp = apps.find(x => !ootbApps.includes(x.name) && !removedApps.includes(x.name)); | |
} | |
} | |
)(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment