Skip to content

Instantly share code, notes, and snippets.

@falfox
Last active October 23, 2023 17:20
Show Gist options
  • Select an option

  • Save falfox/1c8c815489aade5458f890cb6b87712a to your computer and use it in GitHub Desktop.

Select an option

Save falfox/1c8c815489aade5458f890cb6b87712a to your computer and use it in GitHub Desktop.

Revisions

  1. falfox revised this gist Oct 23, 2023. No changes.
  2. falfox revised this gist Sep 6, 2023. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion script.js
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,12 @@ let destiny2 = tx.filter(t => {

    let sum = destiny2.reduce((acc, cur) => acc + parseInt(cur.total), 0)

    const numberFormat = new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR"
    });

    console.log({
    sum
    sum,
    inRupiah: numberFormat.format(sum)
    })
  3. falfox revised this gist Sep 6, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    let tb = document.querySelector('table.wallet_history_table')

    let tx = [...tb.querySelectorAll('tbody tr')].map(tr => {
    let totalRaw = tr.querySelector('.wht_total')?.textContent?? ""
    let total = totalRaw.replace("Credit", '').trim().substring(3).replace(/\s/g,"")
  4. falfox created this gist Sep 6, 2023.
    22 changes: 22 additions & 0 deletions script.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    let tx = [...tb.querySelectorAll('tbody tr')].map(tr => {
    let totalRaw = tr.querySelector('.wht_total')?.textContent?? ""
    let total = totalRaw.replace("Credit", '').trim().substring(3).replace(/\s/g,"")
    let items = tr.querySelector('.wht_items > div')?.textContent.trim() ?? ""
    let isGift = tr.querySelector('.help_purchase_img') !== null

    return {
    total,
    items,
    isGift
    }
    })

    let destiny2 = tx.filter(t => {
    return t.items.startsWith('Destiny 2') && !t.isGift
    })

    let sum = destiny2.reduce((acc, cur) => acc + parseInt(cur.total), 0)

    console.log({
    sum
    })