簡易コメ率

かんたんコメント率を表示

// ==UserScript==
// @name         簡易コメ率
// @namespace    tanbatsu
// @version      0.1
// @author       You
// @grant        unsafeWindow
// @description  かんたんコメント率を表示
// @license      MIT
// @match        https://www.nicovideo.jp/watch/sm*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nicovideo.jp
// @grant        none
// ==/UserScript==

(() => {
	const isTarget = response => response.url.startsWith("https://nvcomment.nicovideo.jp/v1/threads");
	const changeJson = json => {
        console.log(json.data.threads[2].commentCount)
        document.getElementsByClassName("FormattedNumber")[1].innerHTML+="<small>(簡易コメ率:"+Math.floor(json.data.threads[2].commentCount/json.data.globalComments[0].count*100 * Math.pow( 10, 1 ) ) / Math.pow( 10, 1 )+ "%)</small>"
		return json;
	};

	const originalJson = window.Response.prototype.json;

	window.Response.prototype.json = function (...args) {
		const response = this;
		return originalJson.apply(this, args).then(json => {
			if (isTarget(response)) {
				return changeJson(json);
			}
			return json;
		});
	};
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址