您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Ergänzt eine Zeile mit den Spaltensummen zur Creditsübersicht
当前为
// ==UserScript== // @name * Saldo // @namespace bos-ernie.leitstellenspiel.de // @version 1.0.0 // @license BSD-3-Clause // @author BOS-Ernie // @description Ergänzt eine Zeile mit den Spaltensummen zur Creditsübersicht // @match https://www.leitstellenspiel.de/credits/overview // @icon https://www.google.com/s2/favicons?sz=64&domain=leitstellenspiel.de // @run-at document-idle // @grant none // @resource https://forum.leitstellenspiel.de/index.php?thread/25282-script-saldo-by-bos-ernie/ // ==/UserScript== (function () { const table = document.querySelector("table"); function reorderColumns() { const rows = table.rows; for (let i = 0; i < rows.length; i++) { const row = rows[i]; const cells = row.cells; const balanceCell = cells[0]; const revenueCell = cells[1]; const expenditureCell = cells[2]; const dateCell = cells[3]; row.removeChild(balanceCell); row.removeChild(revenueCell); row.removeChild(expenditureCell); row.removeChild(dateCell); row.appendChild(dateCell); row.appendChild(revenueCell); row.appendChild(expenditureCell); row.appendChild(balanceCell); } } function sum(columnIndex) { const cells = table.querySelectorAll(`tbody tr td:nth-child(${columnIndex})`); let sum = 0; cells.forEach(cell => { sum += parseInt(cell.textContent.replace(/\./g, "")); }); return sum; } function addFooter() { const sumOfRevenue = sum(2); const sumOfExpenditure = sum(3); const sumOfBalance = sum(4); const dateCell = document.createElement("td"); dateCell.textContent = "Summe"; const revenueCell = document.createElement("td"); revenueCell.textContent = sumOfRevenue.toLocaleString(); const expenditureCell = document.createElement("td"); expenditureCell.textContent = sumOfExpenditure.toLocaleString(); const balanceCell = document.createElement("td"); balanceCell.classList.add(sumOfBalance < 0 ? "text-danger" : "text-success"); balanceCell.textContent = sumOfBalance.toLocaleString(); const footerRow = document.createElement("tr"); footerRow.style.fontWeight = "bold"; footerRow.appendChild(dateCell); footerRow.appendChild(revenueCell); footerRow.appendChild(expenditureCell); footerRow.appendChild(balanceCell); const footer = document.createElement("tfoot"); footer.appendChild(footerRow); table.appendChild(footer); } function main() { table.querySelector("thead tr th").textContent = "Saldo"; reorderColumns(); addFooter(); } main(); })();