Skip to content

Instantly share code, notes, and snippets.

@LeoDT
Created January 2, 2020 08:42
Show Gist options
  • Save LeoDT/362a09f22ee6487bc6f0401b94cc89cb to your computer and use it in GitHub Desktop.
Save LeoDT/362a09f22ee6487bc6f0401b94cc89cb to your computer and use it in GitHub Desktop.
const year = '2019';
Array.from(document.querySelectorAll('.wallet_table_row'))
.filter(tr => {
return (
tr.querySelector('.wht_type div:first-child').textContent === '购买' &&
tr.querySelector('.wht_date').textContent.indexOf(year) !== -1
);
})
.map(tr =>
tr
.querySelector('.wht_total')
.textContent.replace('¥', '')
.trim()
)
.reduce((s, i) => s + parseInt(i, 10), 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment