-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenocide-Proton-Newsletters.user.js
More file actions
60 lines (50 loc) · 2.21 KB
/
Genocide-Proton-Newsletters.user.js
File metadata and controls
60 lines (50 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ==UserScript==
// @name Genocide Proton Newsletters
// @namespace Violentmonkey Scripts
// @match https://mail.proton.me/u/0/views/newsletters*
// @grant none
// @version 1.1
// @author -
// @run-at document-idle
// @description Unsubscribe from all Newsletters in Proton.me
// ==/UserScript==
async function genocideNewsletters() {
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
while (true) {
// 1. Find the first unsubscribe button with exact text match
const unsubButton = Array.from(document.querySelectorAll('button'))
.find(btn => btn.textContent.trim() === 'Unsubscribe' && btn.offsetParent !== null);
if (!unsubButton) {
console.log("Finished: No more 'Unsubscribe' buttons found.");
break;
}
unsubButton.click();
console.log("Unsubscribe clicked, waiting for popup...");
await delay(1000);
// 2. Select 'Trash existing' option
const trashOption = Array.from(document.querySelectorAll('label, span'))
.find(el => el.textContent.includes('Trash existing') || el.textContent.includes('Move to Trash'));
if (trashOption) {
trashOption.click();
console.log("Selected 'Trash existing'.");
}
// 3. Find confirmation button with retry logic
let finalConfirmBtn = document.querySelector('button[data-testid="unsubscribe-button"]');
if (!finalConfirmBtn) {
console.log("Button not found. Waiting an extra second...");
await delay(1000);
finalConfirmBtn = document.querySelector('button[data-testid="unsubscribe-button"]');
}
// 4. Final Click and Cooldown
if (finalConfirmBtn) {
finalConfirmBtn.click();
console.log("Final confirmation clicked.");
await delay(1000); // Wait for the UI to clear the newsletter from the list
} else {
console.log("Could not find the confirm button after waiting. Refreshing list...");
// If it gets stuck, we click elsewhere or just wait to avoid a loop
await delay(2000);
}
}
}
setTimeout(genocideNewsletters, 3000);