wrtbwmon Total Display

Appends the Download and Upload totals to the default table for wrtbwmon.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        wrtbwmon Total Display
// @namespace   wrtbwmon total display
// @description Appends the Download and Upload totals to the default table for wrtbwmon.
// @include     http://192.168.1.1/cgi-bin/usage
// @include     http://192.168.1.1/usage.htm
// @version     1
// @grant       none
// ==/UserScript==
var oTable = document.getElementsByTagName('tbody');
var oRows = oTable[0].getElementsByTagName('tr');
var downloadTotal = 0;
var uploadTotal = 0;
var totalTotal = 0;
for (i = 1; i < oRows.length; i++) {
  var oCells = oRows[i].getElementsByTagName('td');
  if (oCells[1].innerHTML.endsWith('M') == true) {
    var download = parseFloat(oCells[1].innerHTML) / 1000;
  } else if (oCells[1].innerHTML.endsWith('k') == true) {
    var download = parseFloat(oCells[1].innerHTML) / 1000000;
  } else {
    var download = parseFloat(oCells[1].innerHTML);
  }
  if (oCells[2].innerHTML.endsWith('M') == true) {
    var upload = parseFloat(oCells[2].innerHTML) / 1000;
  } else if (oCells[2].innerHTML.endsWith('k') == true) {
    var upload = parseFloat(oCells[2].innerHTML) / 1000000;
  } else {
    var upload = parseFloat(oCells[2].innerHTML);
  }
  if (oCells[3].innerHTML.endsWith('M') == true) {
    var total = parseFloat(oCells[3].innerHTML) / 1000;
  } else if (oCells[3].innerHTML.endsWith('k') == true) {
    var total = parseFloat(oCells[3].innerHTML) / 1000000;
  } else {
    var total = parseFloat(oCells[3].innerHTML);
  }
  downloadTotal = downloadTotal + download;
  uploadTotal = uploadTotal + upload;
  totalTotal = totalTotal + total;
}
downloadTotal = Math.floor(downloadTotal * 1000) / 1000;
uploadTotal = Math.floor(uploadTotal * 1000) / 1000;
totalTotal = Math.floor(totalTotal * 1000) / 1000;
oTable[0].insertAdjacentHTML('beforeend', '<tr><td><b><h2>Total:</h2></b></td><td>' + downloadTotal + ' G</td><td>' + uploadTotal + ' G</td><td>' + totalTotal + ' G</td><td></td><td></td>')