ニコ生ゲーム中のシークバー移動を防止

追っかけ配信ではない、かつ再生中、かつニコ生ゲーム中の場合に、シークバー移動をブロックすることで、意図せず追っかけ配信へ切り替わってしまう問題に対処します。

当前为 2021-04-14 提交的版本,查看 最新版本

// ==UserScript==
// @name        ニコ生ゲーム中のシークバー移動を防止
// @description 追っかけ配信ではない、かつ再生中、かつニコ生ゲーム中の場合に、シークバー移動をブロックすることで、意図せず追っかけ配信へ切り替わってしまう問題に対処します。
// @namespace   https://gf.qytechs.cn/users/137
// @version     1.0.0
// @match       https://live.nicovideo.jp/watch/lv*
// @license     MPL-2.0
// @contributionURL https://www.amazon.co.jp/registry/wishlist/E7PJ5C3K7AM2
// @compatible  Edge
// @compatible  Firefox 推奨
// @compatible  Opera
// @compatible  Chrome
// @grant       dummy
// @noframes
// @icon        https://nicolive.cdn.nimg.jp/relive/common-resources/44.0.0/images/common/favicon.ico
// @author      100の人
// @homepageURL https://gf.qytechs.cn/users/137
// ==/UserScript==

'use strict';

document.head.insertAdjacentHTML('beforeend', `<style>
	[class*="seek-controller"][aria-disabled="true"]::after {
		content: "";
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
		cursor: not-allowed;
	}
</style>`);

const seekController = document.querySelector('[class*="seek-controller"]');
const playButton = document.querySelector('[class*="play-button"]');
const liveStatus = document.querySelector('[data-live-status]');
const lockItemArea = document.querySelector('[class*="lock-item-area"]');

function switchEnabled()
{
	seekController.setAttribute('aria-disabled', /* 追っかけ再生中ではない */ liveStatus.dataset.liveStatus === 'live'
		&& /* 再生中 */ playButton.dataset.toggleState === 'true'
		&& /* ゲーム中 */ lockItemArea.querySelector('[data-content-type="game"]') ? 'true' : 'false');
}

switchEnabled();
new MutationObserver(switchEnabled).observe(liveStatus, { attributeFilter: [ 'data-live-status' ] });
new MutationObserver(switchEnabled).observe(playButton, { attributeFilter: [ 'data-toggle-state' ] });
new MutationObserver(switchEnabled).observe(lockItemArea, { childList: true });

QingJ © 2025

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