forked from sebastienvercammen/ptc-acc-gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmailverify.js
57 lines (44 loc) · 1.8 KB
/
gmailverify.js
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
/*
Automatically click all "Verify your email" links in the welcome e-mail from
Nintendo Pokémon Trainer Club's signup e-mails.
Original code by Seb <3
All verified e-mails will be moved to trash unless you set "moveToTrash" to false.
How to use:
1. Login to Gmail
2. Go to https://script.google.com/
3. Enter the code, save, run.
4. Wait until fully completed, DO NOT LEAVE THE PAGE! (When finished, the text "running..." at the top will disappear.)
5. Click View > Logs. At the bottom you'll see the total accounts verified.
6. Enjoy
*/
function myFunction() {
var verified = 0;
var moveToTrash = true;
var threads = GmailApp.search('in:inbox subject:"Pokémon Trainer Club Activation"');
Logger.log("Found " + threads.length + " threads.");
threads.forEach(function(thread) {
var messages = thread.getMessages();
Logger.log("Found " + messages.length + " messages.");
messages.forEach(function(msg) {
var value = msg.getBody()
.match(/Verify your email/m);
if(msg.isInInbox() && value) {
var link = msg.getBody().match(/<a href="https:\/\/club.pokemon.com\/us\/pokemon-trainer-club\/activated\/([\w\d]+)"/);
if(link) {
var url = 'https://club.pokemon.com/us/pokemon-trainer-club/activated/' + link[1];
var options = {
"muteHttpExceptions": true
};
var status = UrlFetchApp.fetch(url, options).getResponseCode();
Logger.log("[#] Verified (" + status + "): " + url);
if(status == 200) {
verified++;
msg.markRead();
if(moveToTrash) { msg.moveToTrash(); }
}
}
}
});
});
Logger.log("Completed " + verified + " verifications.");
}