LA_

Untitled

LA_
Aug 21st, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function myFunction() {
  2.   var verified=0;
  3.   var threads = GmailApp.getInboxThreads(0, 200);
  4.   for (var i = 0; i < threads.length; i++) {
  5.     Logger.log(threads[i].getFirstMessageSubject());
  6.     var messages = threads[1].getMessages();
  7.     for(var j =0; j < messages.length; j++)
  8.     {
  9.       var msg=messages[j];
  10.       if(msg.getSubject() === "Pokémon Trainer Club Activation" && msg.isUnread()) {
  11.         var value = msg.getBody()
  12.                        .match(/Verify your email/m);
  13.         if(value) {
  14.           var link = msg.getBody().match(/<a href="https:\/\/club.pokemon.com\/us\/pokemon-trainer-club\/activated\/([\w\d]+)"/);
  15.           if(link) {
  16.             var url = 'https://club.pokemon.com/us/pokemon-trainer-club/activated/' + link[1];
  17.             var status = UrlFetchApp.fetch(url).getResponseCode();
  18.             Logger.log("[#] Verified (" + status + "): " + url);
  19.             if(status == 200) { verified++; GmailApp.markMessageRead(msg);}
  20.           }
  21.         }
  22.       }
  23.     }
  24.   }
  25.   Logger.log("Completed " + verified + " verifications.");
  26. }
Add Comment
Please, Sign In to add comment