-
-
Save matiassingers/8594681 to your computer and use it in GitHub Desktop.
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
// visit: https://just-eat.dk/member/prevorders | |
// run it once per year | |
var siblings = $('#ctl00_ContentPlaceHolder1_rightbox a[href^="javascript:__doPostBack(\'ctl00$ContentPlaceHolder1$ctl00$ctl"').siblings(), | |
sum = isNaN(localStorage.getItem('JE')) ? 0 : parseInt(localStorage.getItem('JE'), 10), | |
yearSum = 0; | |
$('#ctl00_ContentPlaceHolder1_rightbox table tbody tr').each(function(){ | |
var amount = parseInt($(this).find('td').eq(3).find('div').find('div').eq(0).text(), 10); | |
if (isNaN(amount)) return; | |
yearSum += amount; | |
}); | |
console.log('Total in', getYear() + ':', yearSum); | |
localStorage.setItem(getYear(), yearSum); | |
console.log('Total so far:', getTotal()); | |
localStorage.setItem('JE', getTotal()); | |
function getTotal(){ | |
var total = 0; | |
for (var i = 0; i < siblings.length; i += 2) { | |
total += isNaN(localStorage.getItem($(siblings[i]).text())) || !localStorage.getItem($(siblings[i]).text()) ? 0 : parseInt(localStorage.getItem($(siblings[i]).text()), 10); | |
} | |
return total; | |
} | |
function getYear(){ | |
for (var i = 0; i < siblings.length; i += 2) { | |
if($(siblings[i]).attr('disabled') == 'disabled') | |
return $(siblings[i]).text(); | |
} | |
} |
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
var siblings=$('#ctl00_ContentPlaceHolder1_rightbox a[href^="javascript:__doPostBack(\'ctl00$ContentPlaceHolder1$ctl00$ctl"').siblings(),sum=isNaN(localStorage.getItem('JE'))?0:parseInt(localStorage.getItem('JE'),10),yearSum=0;$('#ctl00_ContentPlaceHolder1_rightbox table tbody tr').each(function(){var amount=parseInt($(this).find('td').eq(3).find('div').find('div').eq(0).text(),10);if(isNaN(amount))return;yearSum+=amount});console.log('Total in',getYear()+':',yearSum);localStorage.setItem(getYear(),yearSum);console.log('Total so far:',getTotal());localStorage.setItem('JE',getTotal());function getTotal(){var total=0;for(var i=0;i<siblings.length;i+=2){total+=isNaN(localStorage.getItem($(siblings[i]).text()))||!localStorage.getItem($(siblings[i]).text())?0:parseInt(localStorage.getItem($(siblings[i]).text()),10)}return total}function getYear(){for(var i=0;i<siblings.length;i+=2){if($(siblings[i]).attr('disabled')=='disabled')return $(siblings[i]).text()} |
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
// list all year totals | |
var siblings = $('#ctl00_ContentPlaceHolder1_rightbox a[href^="javascript:__doPostBack(\'ctl00$ContentPlaceHolder1$ctl00$ctl"').siblings() | |
for (var i = 0; i < siblings.length; i += 2) { | |
console.log($(siblings[i]).text(), parseInt(localStorage.getItem($(siblings[i]).text()), 10)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment