Last active
April 11, 2025 16:31
-
-
Save drazulay/70d7c4193cffee4e72fd9976f8a0d529 to your computer and use it in GitHub Desktop.
Javascript to quickly delete all defined spam filers in protonmail settings in the web environment.
This file contains hidden or 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
const getDomainKeys = () => Object.entries(Array.from(document.querySelectorAll('#spam tbody tr[role="row"]'))).flatMap(el => { | |
Object.entries(el[1]).find(v => v[0].startsWith('__reactFiber$'))[1].return.key); | |
}; | |
const deleteDomainsByKeys = async (ids) => { | |
await fetch("https://account.proton.me/api/mail/v4/incomingdefaults/delete", { | |
"credentials": "include", | |
"headers": { | |
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0", | |
"Accept": "application/vnd.protonmail.v1+json", | |
"Accept-Language": "nl,en-US;q=0.7,en;q=0.3", | |
"x-pm-appversion": "[email protected]", | |
"x-pm-uid": "66n6fltrslgbw465u2tbhzklu3aoxajb", | |
"content-type": "application/json", | |
"Sec-Fetch-Dest": "empty", | |
"Sec-Fetch-Mode": "cors", | |
"Sec-Fetch-Site": "same-origin", | |
"Sec-GPC": "1", | |
"Priority": "u=0" | |
}, | |
"referrer": "https://account.proton.me/u/2/mail/filters", | |
"body": JSON.stringify({ | |
IDs: ids | |
}), | |
"method": "PUT", | |
"mode": "cors" | |
}) | |
}; | |
// Usage: | |
// | |
// deleteDomainsByKeys(getDomainKeys()); document.querySelector('#spam button[title="Next"]').click() | |
// | |
// After doing this a number of times, you may have to reset the pager to page 1 and start again. | |
// Repeat until all pages have been deleted. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment