Last active
August 29, 2015 14:24
-
-
Save lackneets/dcfda5486af77fe62dc3 to your computer and use it in GitHub Desktop.
Download Gmail in Group save by Receiver
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
javascript: function gmailRawURL(t){return"//mail.google.com/mail/"+String(location).match(/(u\/\d*\/)/)+"?ik="+GLOBALS[9]+"&view=om&th="+t}function downloadURL(t,a){var o=document.createElement("a");o.setAttribute("href",a),o.setAttribute("download",t),o.click(),console.log("Download",a,"as",t)}function download(t,a){var o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(a)),o.setAttribute("download",t),o.click()}Array.prototype.forEach.call($$(".kQ"),function(t){t.click()}),Array.prototype.forEach.call($$(".kv .adf"),function(t){t.click()}),Array.prototype.forEach.call($$(".h7 .hb .g2.ac2"),function(t){console.log(t.getAttribute("email"))});var mails=$$(".adP.adO"),recieverEmails=Array.prototype.map.call($$(".h7 .hb .g2.ac2"),function(t){return t.getAttribute("email")}),mailUrls=[];for(var i in mails)id=String(mails[i].className).match(/m([\d\w]+)/),id&&mailUrls.push(gmailRawURL(id[1]));mailUrls.forEach(function(t,a){downloadURL(recieverEmails[a]+".eml",t)}); |
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
/* | |
Paste this in console | |
*/ | |
// 展開群組 Expand Groups | |
Array.prototype.forEach.call($$('.kQ'), function(hidden){ | |
hidden.click(); | |
}); | |
Array.prototype.forEach.call($$('.kv .adf'), function(hidden){ | |
hidden.click(); | |
}); | |
Array.prototype.forEach.call($$('.h7 .hb .g2.ac2'), function(reciever){ | |
console.log(reciever.getAttribute('email')); | |
}); | |
function gmailRawURL(id){ | |
return '//mail.google.com/mail/' + String(location).match(/(u\/\d*\/)/) + '?ik=' + GLOBALS[9] + '&view=om&th=' + id; | |
} | |
var mails = $$('.adP.adO'); | |
var recieverEmails = Array.prototype.map.call($$('.h7 .hb .g2.ac2'), function(reciever){ | |
return reciever.getAttribute('email'); | |
}); | |
var mailUrls = []; | |
for(var i in mails){ | |
id = String(mails[i].className).match(/m([\d\w]+)/); | |
id && mailUrls.push(gmailRawURL(id[1])); | |
} | |
mailUrls.forEach(function(url, k){ | |
downloadURL(recieverEmails[k] + ".eml", url); | |
}) | |
function downloadURL(filename, url) { | |
var pom = document.createElement('a'); | |
pom.setAttribute('href', url); | |
pom.setAttribute('download', filename); | |
pom.click(); | |
console.log('Download', url, 'as', filename); | |
} | |
function download(filename, text) { | |
var pom = document.createElement('a'); | |
pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
pom.setAttribute('download', filename); | |
pom.click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment