Skip to content

Instantly share code, notes, and snippets.

@jhonnymoreira
Created August 30, 2020 22:31
Show Gist options
  • Save jhonnymoreira/e94abedcb32a2a2c021c7626546715b7 to your computer and use it in GitHub Desktop.
Save jhonnymoreira/e94abedcb32a2a2c021c7626546715b7 to your computer and use it in GitHub Desktop.
Calculo da quantia a ser paga de DAS-MEI em um determinado intervalo.
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' });
};
@jhonnymoreira
Copy link
Author

Uso

  • Copie o código
  • Cole no console do navegador (F12)
// Cálculo do intervalo entre Abril e Dezembro
getMEIDebt(3, 12) //=> R$ 503,10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment