Skip to content

Instantly share code, notes, and snippets.

@AdamEsterle
Created May 27, 2015 18:34
Show Gist options
  • Save AdamEsterle/bd914830d82fc1f6ae8d to your computer and use it in GitHub Desktop.
Save AdamEsterle/bd914830d82fc1f6ae8d to your computer and use it in GitHub Desktop.
var data = {};
var dollars = {};
jQuery.get( "https://www.att.com/olam/billUsageTiles.myworld", function( mbData ) {
var names = [];
jQuery(mbData).find('p.font14.botMar0 > strong').each(function(i) {
names.push(jQuery(this).text().trim());
});
jQuery(mbData).find('a[title="Web Usage"]').each(function(i) {
data[names[i]] = parseFloat(jQuery(this).find('span > strong').text().trim()) * 1024;
});
var rollOverData = '';
rollOverData = parseFloat(jQuery(mbData).find('#wirelessRolloverBookPopup tbody > tr:eq(0) > td:eq(2) > strong').text().trim()) * 1024;
jQuery.get( "https://www.att.com/olam/billOverviewTiles.myworld", function( dollarData ) {
var names = [];
jQuery(dollarData).find('a.MarRight10').each(function(i) {
var name = jQuery(this).text().trim();
names.push(name.substring(0, name.length - 12).trim());
});
var totalBill = '';
totalBill = jQuery(dollarData).find('span.billingOrangeText.font32.rel').text().trim();
jQuery(dollarData).find('span.flipper.float-right.font14.top10px.padRight20.colorBlack').not('.ie7Top7').each(function(i) {
dollars[names[i]] = jQuery(this).text().trim();
});
var stringForGoogleSheets = '';
stringForGoogleSheets += totalBill + '\n';
stringForGoogleSheets += rollOverData + '\n';
stringForGoogleSheets += combineDollarsAndData(dollars, data);
jQuery('body').prepend('<textarea style="width:200px;height:200px;" id="COPYME"></textarea>');
jQuery('#COPYME').val(stringForGoogleSheets).focus().select();
});
});
function combineDollarsAndData(dollars, data){
// Expected format
// dollars["Adam"] = 65
// data["Adam"] = 4500
// order will matter
// AT&T orders by phone number
var combinedString = '';
for (var i in dollars) {
combinedString += dollars[i] + "\t" + data[i] + "\n";
};
return combinedString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment