Turn off Nicomment LS

ニコニコ動画のコメントをデフォルトで非表示にする

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Turn off Nicomment LS
// @namespace    https://at.sachi-web.com/turn-off-nicomment-ls.html
// @version      1.0.190614
// @description  ニコニコ動画のコメントをデフォルトで非表示にする
// @author       うみのさち
// @match        https://www.nicovideo.jp/watch/*
// @grant        none
// @noframes
// ==/UserScript==

( ()=> {
'use strict';

const interval = 250;
const timeover = 10000;

const turnoff = {
	'html': ()=> {
		document.getElementsByClassName('CommentOnOffButton')[0].click();
	},
	'flash': ()=> {
		player.ext_setCommentVisible(false);
	}
};
let time = 0;

let player = document.getElementById('external_nicoplayer');
let type = player ? 'flash' : 'html';

let timer = setInterval( ()=> {
	try {
		time += interval;
		if( time <= timeover ) turnoff[type]();
		clearInterval(timer);
	} catch(e) {
		// player isn't ready
	}
}, interval);

})();