Skip to content

Instantly share code, notes, and snippets.

@rodvlopes
Last active March 22, 2020 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodvlopes/2d91758fc4a26e317cd86ecf26756527 to your computer and use it in GitHub Desktop.
Save rodvlopes/2d91758fc4a26e317cd86ecf26756527 to your computer and use it in GitHub Desktop.
Adiciona o preço médio e ao BastterSystem
/*
Na tela de "Ações", abra o console e cole o snippet abaixo. Depois nevegue pelas movitações.
*/
function injectPrecoMedio() {
$('<th>Cotação</th>').insertAfter('#acaoDatasCompra .itens thead tr th:nth-child(4)')
$('<th>R$ Médio</th>').insertAfter('#acaoDatasCompra .itens thead tr th:nth-child(8)')
$.merge($('#acaoDatasCompra .itens .compra '),$('#acaoDatasCompra .itens .subscrição ')).toArray().forEach(
tr => {
const [d, t, q, v, x, qt, vt] = $('td', tr).toArray();
const vlr = parseFloat($(v).text().replace('.', '').replace(',', '.'));
const qnt = parseInt($(q).text().replace('.', ''));
const vlrT = parseFloat($(vt).text().replace('.', '').replace(',', '.'));
const qntT = parseInt($(qt).text().replace('.', ''));
const cotacao = vlr/qnt;
const precoMedio = vlrT/qntT;
console.log('tr', tr);
$(`<td>${cotacao.toFixed(2).replace('.', ',')}</td>`).insertAfter($('td:nth-child(4)', tr));
$(`<td>${precoMedio.toFixed(2).replace('.', ',')}</td>`).insertAfter($('td:nth-child(8)', tr));
});
}
$('.option.icon-plus-fa.tooltiped').click(e => {
setTimeout(injectPrecoMedio, 2000);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment