/* Automatically click all "Verify your email" links in the welcome e-mail from Nintendo Pokémon Trainer Club's signup e-mails. Only unread emails in inbox will be processed. All processed e-mails will be marked as read if verification was successful, and optionally moved to trash if it's enabled in your settings. How to use: 1. Login to Gmail 2. Go to https://script.google.com/ 3. Enter the code in Code.gs and index.html (if index.html doesn't exist, create it). 4. Edit the settings at the top of index.html. 5. In the editor, click on Resources > Advanced Google services and name your project. 6. Enable "These services must also be enabled in the Google Developers Console". 7. Enable GMail API for your new project in the Google Developers Console: https://console.developers.google.com/. 8. Click Publish, then run as web app. 9. You'll see the results on the page. Dev console can be used for debugging. 10. Enjoy */ // Serve HTML file. function doGet() { return HtmlService.createHtmlOutputFromFile('index.html'); } function getAllEmailLinks(limit) { // Prepare response. var items = []; // Start. var threads = GmailApp.search('in:inbox -label:RM_EXPIRED -label:RM_PREACTIVATED is:unread subject:"Pokémon Trainer Club Activation"', 0, limit); Logger.log("Found " + threads.length + " threads."); threads.forEach(function (thread) { var messages = thread.getMessages(); Logger.log("Found " + messages.length + " messages."); messages.forEach(function (msg) { // If we have a limit, follow it. if (limit > 0 && items.length >= limit) { return; } var value = msg.getBody() .match(/verify your email/m); if (msg.isInInbox() && value) { var messageId = msg.getId(); var link = msg.getBody().match(/