Skip to content

Instantly share code, notes, and snippets.

@jhonnymoreira
Created August 30, 2020 22:31

Revisions

  1. jhonnymoreira created this gist Aug 30, 2020.
    13 changes: 13 additions & 0 deletions getMEIDebt.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    const getMEIDebt = (indexBegin, length) => {
    const NODE_SELECTOR = '.total.updatable.text-center';

    const sum = (x, y) => x + y;
    const normalizeValue = (value) =>
    value.replace('R$', '').replace(',', '.').trim();

    return Array.from(document.querySelectorAll(NODE_SELECTOR))
    .slice(indexBegin, length)
    .map((node) => parseFloat(normalizeValue(node.innerText)))
    .reduce(sum, 0)
    .toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' });
    };