Created
August 23, 2018 02:47
-
-
Save Rikezenho/579c9b838f405ff4a0e0ac7fbad0844a to your computer and use it in GitHub Desktop.
Script para pegar o preço total de Ubers na fatura Nubank/Santander (basta estar na tela da fatura atual e executar o código)
This file contains 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
var toSearch = 'uber'; | |
var qtdViagens = 0; | |
var values = []; | |
if (window.location.href.indexOf('santander') > -1) { | |
values = [...document.querySelectorAll('.cartoescontainerjson02 .contenido-activo .tabla_datos:first-child tr')].map((el) => { | |
if ([...el.querySelectorAll('td')][1] && [...el.querySelectorAll('td')][1].innerHTML.toLowerCase().indexOf(toSearch) > -1) { | |
return el.querySelector('td p').innerHTML; | |
} | |
}).map((el) => { | |
return (el !== undefined) ? (qtdViagens++, +el.replace(',', '.')) : 0; | |
}); | |
} else if (window.location.href.indexOf('nubank') > -1) { | |
values = [...document.querySelectorAll('.md-tab-content:not(.ng-hide) .charge-data')].map((el) => { | |
if (el.querySelector('.description').innerHTML.toLowerCase().indexOf(toSearch) > -1) { | |
return el.querySelector('.amount').innerHTML; | |
} | |
}).map((el) => { | |
return (el !== undefined) ? (qtdViagens++, +el.replace(',', '.')) : 0; | |
}); | |
} | |
var finalValue = values.reduce((prev, curr) => { return prev + curr; }); | |
console.log(`Valores de Uber:`, values); | |
console.log(`Quantidade de viagens:`, qtdViagens); | |
console.log(`Preço final: ${finalValue.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' })}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment