知乎赞同数用K显示
当前为
// ==UserScript==
// @name Zhihu-K
// @namespace https://github.com/rain15z3/Zhihu-K
// @version 1.1
// @description 知乎赞同数用K显示
// @author RainbowBird
// @match https://www.zhihu.com/*
// @grant none
// @require http://code.jquery.com/jquery-1.11.0.min.js
// ==/UserScript==
!(function () {
console.log("[Zhihu-K] loading...");
setInterval(refrush, 50);
})();
function refrush() {
$(".VoteButton--up").each(function () {
var text = $(this).contents().eq(1).get(0).nodeValue;
text = text.replace(/\u200B/g, "");
var flag = "赞同 ";
if (text.match("已赞同")) {
flag = "已赞同 ";
}
var rep = text.replace(flag, "");
if (text.match("万")) {
rep = rep.replace(" 万", "");
var num = parseFloat(rep) * 10000;
} else {
var num = parseFloat(rep);
}
if (num >= 10000 || (num >= 1000 && num < 10000)) {
var numk = num / 1000;
if (numk.toString().match(".")) numk = numk.toFixed(1);
text = flag + numk + " K";
}
$(this).contents().eq(1).get(0).nodeValue = text;
});
}