Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Mostra o valor total gasto em propinas
Browse files Browse the repository at this point in the history
  • Loading branch information
DCruzDev committed Jun 2, 2019
1 parent b218567 commit 222a8b8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions js/moneySpent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
mainTable = document.querySelector("#template_main > p:nth-child(12) > table:nth-child(1) > tbody:nth-child(1)").children;
stats = parseMainTable(mainTable);
writeStats(stats);

// Write stats on table at the end of page
function writeStats(stats){
tableToWrite = document.querySelector("tr.table_line:nth-child(33) > td:nth-child(1)");

//Create Element to add
var newNode1 = document.createElement("p");
var newB = document.createElement("b");

newB.innerText = "Dinheiro total gasto em propinas: " + stats["totalmoney"].toFixed(2) + "€";
newNode1.appendChild(newB);

//Add elements
tableToWrite.insertBefore(newNode1, tableToWrite.childNodes[0]);
}

function parseMainTable (table){
sum = 0;
// Go Through each row
for(i=2;i<table.length-3;i++){
row = table[i].children;
console.log(row);
text = row[1].innerHTML;
value = text.split(" ")[0].replace(",",".");
sum = sum + parseFloat(value);
};
stats = {};
stats["totalmoney"] = sum;
return stats;
}


6 changes: 5 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "PACO UA Extension",
"version": "0.24",
"version": "0.25",

"description": "Adiciona funcionalidade ao antigo PACO da Universidade de Aveiro",

Expand All @@ -18,6 +18,10 @@
{
"matches": ["https://paco.ua.pt/secvirtual/c_calendarioDeExames.asp"],
"js": ["js/examsCalendar.js"]
},
{
"matches": ["https://paco.ua.pt/secvirtual/c_estadoDasProprinas.asp"],
"js": ["js/moneySpent.js"]
}
],

Expand Down

0 comments on commit 222a8b8

Please sign in to comment.