Last active
March 19, 2025 18:52
-
-
Save mageddo/279a048a8c8cc8d2f5a1ad01fe2dd2ad to your computer and use it in GitHub Desktop.
Lista Melhores Investimentos Banco Inter
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
// ==UserScript== | |
// @name Lista Melhores Investimentos | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-04-15 | |
// @description entre na pagina dos investimentos de renda fixa e rode, ele tratá os top investimentos cri, cra, deb por ordem de taxa | |
// @author You | |
// @match https://contadigital.inter.co/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=inter.co | |
// @grant none | |
// ==/UserScript== | |
// https://gist.github.com/mageddo/279a048a8c8cc8d2f5a1ad01fe2dd2ad/edit | |
(function() { | |
'use strict'; | |
// quando clicar na lista de investimentos | |
let btn = document.createElement("button"); | |
btn.innerHTML = "melhores investimentos"; | |
document.body.prepend(btn); | |
function findInvestmentDivs(){ | |
let divs = document.querySelectorAll("div div div span"); | |
let wantedDivs = []; | |
divs.forEach((v) => { | |
if(/^(?:CDB|CRI|CRA|DEB)/.test(v.innerText)){ | |
wantedDivs.push(v); | |
} | |
}); | |
return wantedDivs; | |
} | |
btn.onclick = function(){ | |
let investmentsDiv = findInvestmentDivs(); | |
let investments = []; | |
for (let k in investmentsDiv){ | |
let investmentDiv = investmentsDiv[k]; | |
let inv = toInvestment(investmentDiv); | |
if(inv){ | |
investments.push(inv); | |
} | |
} | |
// mais rentáveis primeiro | |
investments.sort(function(a, b){ | |
return b.tax - a.tax; | |
}); | |
filterAndPrint(investments, "CDI"); | |
filterAndPrint(investments, "IPCA"); | |
} | |
function filterAndPrint(investments, group){ | |
let str = "TOP " + group + "\n"; | |
investments | |
.filter((it) => { | |
return it.group === group; | |
}) | |
.slice(0, 25) | |
.forEach((v, i) => { | |
str += JSON.stringify(v) + "\n"; | |
}); | |
str += "\n"; | |
console.info(str); | |
} | |
function toInvestment(investmentDiv){ | |
let inv = {title: investmentDiv.innerText}; | |
let reg = /([A-Z]+) \+ ([0-9]+,?[0-9]*)%/; | |
let r = reg.exec(inv.title); | |
if(r === null){ | |
return null; | |
} | |
inv.group = r[1]; | |
inv.tax = parseFloat(r[2].replaceAll(",", ".")); | |
if(!inv.title){ | |
return null; | |
} | |
if(inv.title.startsWith("CRA") || inv.title.startsWith("CRI") || inv.title.startsWith("DEB")){ | |
if(inv.title.includes("IPCA") || inv.title.includes("CDI")){ | |
return inv; | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment