Last active
March 22, 2020 22:26
-
-
Save rodvlopes/2d91758fc4a26e317cd86ecf26756527 to your computer and use it in GitHub Desktop.
Adiciona o preço médio e ao BastterSystem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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