Skip to content

Instantly share code, notes, and snippets.

@mageddo
Created April 30, 2024 23:49
Show Gist options
  • Save mageddo/279a048a8c8cc8d2f5a1ad01fe2dd2ad to your computer and use it in GitHub Desktop.
Save mageddo/279a048a8c8cc8d2f5a1ad01fe2dd2ad to your computer and use it in GitHub Desktop.
Lista Melhores Investimentos Banco Inter
// ==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==
(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;
});
console.info("TOP CDI");
investments.filter((it) => {
return it.group === "CDI";
})
.slice(0, 10)
.forEach((v, i) => {
console.info(v);
});
console.info("TOP IPCA");
investments.filter((it) => {
return it.group === "IPCA";
})
.slice(0, 10)
.forEach((v, i) => {
console.info(v);
});
}
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