Last active
December 4, 2017 21:10
-
-
Save z-hao-wang/3237dec94d9952c11dfb1634206c2ae8 to your computer and use it in GitHub Desktop.
ATT Bill Bookmark
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
//Usage: create a bookmark (add page) in chrome. title type "ATT Bill", URL: paste content below. | |
//Login to att.com, go to your bills and make sure you can view wireless bill details. click on the bookmark. | |
javascript:(function(){for(var allData=$(".faux-table-cell").map(function(a,t){return $(t).text()}),sharedCostFields=["Unlimited Plus Multi Line"],map={},maxAmount=0,sharedCosts=0,output="",i=0;i<allData.length;i++){var row=allData[i];if(row.match(/\d\d\d-\d\d\d-\d\d\d\d/)){var amount=allData[i+1].replace(/\$/,"");map[row]={amount:parseFloat(amount)},amount>maxAmount&&(maxAmount=parseFloat(amount))}for(var j=0;j<sharedCostFields.length;j++)if(row.indexOf(sharedCostFields[j])>-1){var sharedCost=allData[i+1].replace(/\$/,"");sharedCosts+=parseFloat(sharedCost),output+="sharedCost "+row.trim()+": "+sharedCost.trim()+"\n"}}var size=Object.keys(map).length,sharedCostPerLine=sharedCosts/size,total=0;for(var key in map)map[key].amount===maxAmount&&(map[key].amount-=sharedCosts),map[key].amount+=sharedCostPerLine,total+=map[key].amount,output+=key.trim()+":"+map[key].amount.toFixed(2)+"\n";output+="total:"+total.toFixed(2)+"\n",alert(output),console.log(output);})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment