Greasy Fork is available in English.
修改天翼网盘总容量单位显示为G
当前为
// ==UserScript==
// @name 天翼网盘总容量单位显示为G
// @namespace http://greasyfork.icu/zh-CN/users/4330
// @version 2.0
// @description 修改天翼网盘总容量单位显示为G
// @author x2009again
// @match http*://cloud.189.cn/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
function formatFileSize(bytes, fixedDigits, unitFlag, floorFlag) {
debugger;
if (!(bytes.toString().search(/B|K|M|G|T/) > - 1)) {
var humanSize,
unit,
_bytes = parseFloat(bytes),
absBytes = Math.abs(_bytes);
fixedDigits == undefined && (fixedDigits = 2),
unitFlag == undefined && (unitFlag = !0),
// absBytes < 1024 ? (fixedDigits = 0, humanSize = _bytes, unit = 'B') : absBytes < 921600 ? (humanSize = _bytes / 1024, unit = 'K') : absBytes < 943718400 ? (humanSize = _bytes / 1048576, unit = 'M') : absBytes < 966367641600 || 0 === fixedDigits && absBytes < 10995116277760 ? (humanSize = _bytes / 1073741824, unit = 'G') : (humanSize = _bytes / 1099511627776, unit = 'T'),
humanSize = _bytes / 1073741824, unit = 'G',
humanSize = Math.round(humanSize * Math.pow(10, fixedDigits)) / parseFloat(Math.pow(10, fixedDigits)),
humanSize = humanSize.toFixed(fixedDigits);
var result;
return result = floorFlag && fixedDigits > 0 ? humanSize != Math.floor(humanSize) ? humanSize : parseInt(Math.floor(humanSize), 10) : humanSize,
unitFlag && (result += unit),
result
}
}
(function(open) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener("readystatechange", function() {
if(this.responseURL.indexOf("getLoginedInfos")>-1&&this.readyState==3)
{
console.log("测试"+JSON.parse(this.response).quota);
var userLoginedInfosData=JSON.parse(this.response);
setTimeout(function(){
document.querySelector('#J_UsedSpaceTotal').textContent=('总容量:' + formatFileSize(userLoginedInfosData.quota, 2, !0, !1));
},1000);
}
}, false);
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);
})();