4 ms·
Today I contributed to the greater good of society: var output = ""; $('h2 a').each(function(i) { output += "TITLE: " + $.trim(this.innerHTML) + "\n"
by bramgg 12y ago
Today I contributed to the greater good of society:
var output = "";
$('h2 a').each(function(i) {
output += "TITLE: " + $.trim(this.innerHTML) + "\n";
var email = decodeURIComponent(this.href).slice(13).split("&subject=");
output += "SUBJECT: " + email[1] + "\n";
output += "BODY:\n" + email[0].replace(/\n( )+/g, "\n") + "\n\n\n\n";
console.log(output);
});
That being said I love the site :)
- hippich 12y agoconsole.log(output); needs to be last line outside each() :) Or move var content = "" inside each()
- bramgg 12y agoWhoops, you're right, console.log was supposed to be at the very bottom of the script. By default most browser consoles scroll you to the bottom of the output, so I just read the first half scrolling up and never noticed. No matter, amarraja's version is much better.
- amarraja 12y agoSlightly tweaked your script to display inline $("h2 a").each(function(){ var email = decodeURIComponent(this.href).slice(13).split("&subject="); var subject = email[1]; var body = email[0].replace(/\n( )+/g, "\n"); var parent = $(this).parent("h2") parent.after($("<div />").text(body)); parent.after($("<h4 />").text(subject)); });
- bramgg 12y agoThis is great! For anyone wondering, use this one.
- benbowdene 12y agoSO much easier reading it this way :D