page=mouvements:affiche-entrees-sorties

[FR] affiche le total des entrées sorties sur la page de mouvement des comptes

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @id             f356086e-0c23-4cec-b3d3-e8c12dfd94ad
// @name           page=mouvements:affiche-entrees-sorties
// @version        1.1
// @namespace      nil
// @author         nil
// @description    [FR] affiche le total des entrées sorties sur la page de mouvement des comptes
// @include        https://www.boursorama.com/comptes/banque/detail/mouvements.phtml?*
// ==/UserScript==

function showInAndOut() {
  totalIN = 0.0;
  totalOUT = 0.0;

  collection = document.getElementsByClassName("amount");
  if (0 === collection.length) {
    alert("Err1: Userscript showInAndOut probably needs to be updated");
    return;
  }

  for (var elt, i=0; elt = collection.item(i); i++) {
    amount = parseFloat(elt.textContent.replace(/\s+/g, '').replace(',', '.'));
    if(-1 !== elt.className.search('pos')) {
      totalIN += amount;
    } else {
      totalOUT += amount;
    }
  }
  total_tr = collection.item(0).parentNode.parentNode.lastElementChild;

  if (-1 === total_tr.className.search('total')) {
    alert("Err2: Userscript showInAndOut probably needs to be updated");
    return;
  }
  
  td_dest = total_tr.firstElementChild;
  td_dest.innerHTML = td_dest.innerHTML.replace('<br>', '<br>Entrées :<span class=pos> +' + totalIN.toFixed(2) +" EUR</span><br>Sorties : <span class=neg>" + totalOUT.toFixed(2) + " EUR</span><br>");
}

document.addEventListener('DOMContentLoaded', showInAndOut);