Last active
April 18, 2016 23:52
-
-
Save Ribesg/0f68d5e4ff8129bc80acc6a32f428d61 to your computer and use it in GitHub Desktop.
Use on the Beta tab of Fabric to get the list of beta testers as a CSV file. This code is GPLv3.
This file contains 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
(function(){ | |
function escapeCsvValue(str) { | |
var res = str; | |
if (res.indexOf('"') >= 0) { | |
res = res.replace(/"/g, '""'); | |
} | |
if (res.indexOf('"') >= 0 || res.indexOf(' ') >= 0) { | |
res = '"' + res + '"'; | |
} | |
return res; | |
} | |
function parse() { | |
var testers = []; | |
var testersHtml = $('.i_tester'); | |
console.log(testersHtml.length + ' testers found, parsing...'); | |
var i = 0; | |
testersHtml.each(function() { | |
var testerHtml = $(this); | |
var name = testerHtml.find('.identification > .name').first().text(); | |
if (name === '') name = "???"; | |
var email = testerHtml.find('.identification > .email').first().text(); | |
var progress = testerHtml.find('.progress-bar-container').first(); | |
var status; | |
if (progress.hasClass('invited')) { | |
status = 'invited'; | |
} else if (progress.hasClass('accepted')) { | |
status = 'accepted'; | |
} else if (progress.hasClass('installed')) { | |
status = 'installed'; | |
} else if (progress.hasClass('launched')) { | |
status = 'launched'; | |
} else { | |
console.log('No valid class found for object with classes ' + progress.attr('class')); | |
} | |
testers.push({ | |
'email': email, | |
'name': name, | |
'status': status | |
}); | |
console.log('Parsed ' + ++i + '/' + testersHtml.length + ' testers...'); | |
}); | |
var statusScores = { | |
'invited': 0, | |
'accepted': 1, | |
'installed': 2, | |
'launched': 3 | |
}; | |
testers.sort(function(a, b) { | |
if (a.status != b.status) { | |
return statusScores[a.status] < statusScores[b.status] ? -1 : 1; | |
} else { | |
return a.email.toLowerCase().localeCompare(b.email.toLowerCase()); | |
} | |
}); | |
var res = "email,name,status\n"; | |
for (var i in testers) { | |
var tester = testers[i]; | |
res += escapeCsvValue(tester.email) + ','; | |
res += escapeCsvValue(tester.name) + ','; | |
res += escapeCsvValue(tester.status) + '\n'; | |
} | |
document.open(); | |
document.write('<html><body>' + res.split('\n').join('<br/>') + '</body></html>'); | |
document.close(); | |
$('html, body').animate({ scrollTop: 0 }, 0); | |
}; | |
function expand() { | |
var res = $('.expansion-row'); | |
if (res.length > 0) { | |
console.log('Expanding...'); | |
res.each(function() { | |
$(this).click(); | |
}); | |
$('html, body').animate({ scrollTop: $(document).height() }, 0); | |
setTimeout(expand, 50); | |
} else { | |
$('html, body').animate({ scrollTop: $(document).height() }, 0); | |
console.log('Done expanding, getting data...'); | |
parse(); | |
} | |
}; | |
expand(); | |
})(); |
This file contains 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
!function(){function t(t){var e=t;return e.indexOf('"')>=0&&(e=e.replace(/"/g,'""')),(e.indexOf('"')>=0||e.indexOf(" ")>=0)&&(e='"'+e+'"'),e}function e(){var e=[],n=$(".i_tester");console.log(n.length+" testers found, parsing...");var a=0;n.each(function(){var t=$(this),s=t.find(".identification > .name").first().text();""===s&&(s="???");var o,i=t.find(".identification > .email").first().text(),l=t.find(".progress-bar-container").first();l.hasClass("invited")?o="invited":l.hasClass("accepted")?o="accepted":l.hasClass("installed")?o="installed":l.hasClass("launched")?o="launched":console.log("No valid class found for object with classes "+l.attr("class")),e.push({email:i,name:s,status:o}),console.log("Parsed "+ ++a+"/"+n.length+" testers...")});var s={invited:0,accepted:1,installed:2,launched:3};e.sort(function(t,e){return t.status!=e.status?s[t.status]<s[e.status]?-1:1:t.email.toLowerCase().localeCompare(e.email.toLowerCase())});var o="email,name,status\n";for(var a in e){var i=e[a];o+=t(i.email)+",",o+=t(i.name)+",",o+=t(i.status)+"\n"}document.open(),document.write("<html><body>"+o.split("\n").join("<br/>")+"</body></html>"),document.close(),$("html, body").animate({scrollTop:0},0)}function n(){var t=$(".expansion-row");t.length>0?(console.log("Expanding..."),t.each(function(){$(this).click()}),$("html, body").animate({scrollTop:$(document).height()},0),setTimeout(n,50)):($("html, body").animate({scrollTop:$(document).height()},0),console.log("Done expanding, getting data..."),e())}n()}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment