Skip to content

Instantly share code, notes, and snippets.

@rigwild
Last active March 3, 2019 15:05
Show Gist options
  • Save rigwild/c41897eff669cdec0d145cce2024b220 to your computer and use it in GitHub Desktop.
Save rigwild/c41897eff669cdec0d145cce2024b220 to your computer and use it in GitHub Desktop.
Quickly remove all the activity history from a Microsoft Account.
// Go to https://account.microsoft.com/privacy/activity-history
// Select "All activities" on the left panel.
// Open your browser's dev tools (F12), got to the console tab.
// Paste this script, it will load all the history elements and delete all activity.
// If you get spammed by errors in the console, turn your adblocker off temporarily.
// You will probably need to refresh the page and execute this script multiple times :
// The page is (IMHO) intentionnaly buggy to prevent people from deleting their data.
// Eventually everything will be clean.
// Updated and working on 03/03/2019
(async () => {
const timeout = ms => new Promise(res => setTimeout(res, ms))
const canLoadMore = () => document.querySelector('.timeline-load-more a') !== undefined
const loadMore = async () => {
const linkLoadMore = document.querySelector('.timeline-load-more a')
linkLoadMore.click()
console.log('Clicked load more.')
await timeout(3000)
}
const deleteHistory = async () => {
const historyEle = Array.from(document.querySelectorAll('.delete-button'))
for (aHistoryEle of historyEle) {
await timeout(500)
aHistoryEle.click()
console.log('Clicked delete on a history element.')
}
}
// We loop 5 times because the "Load more" is cyclic.
// You see content of the start when you reach the end.
const loop = async () => {
for (let i = 0 ; i < 5 && canLoadMore() ; i++)
await loadMore()
await deleteHistory()
console.log('Did a cycle.')
}
// Delete the history
while (canLoadMore()) await loop()
console.log('Finished cleaning history.')
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment