您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
ニコ動に再生スピード、早送り・巻き戻しのショートカットを追加するスクリプト
当前为
// ==UserScript== // @name ニコ動に再生スピード、早送り・巻き戻しのショートカットを追加する // @namespace http://tampermonkey.net/ // @version 0.2 // @description ニコ動に再生スピード、早送り・巻き戻しのショートカットを追加するスクリプト // @author You // @match https://www.nicovideo.jp/watch/* // @icon https://www.google.com/s2/favicons?sz=64&domain=www.nicovideo.jp // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function ContextMenuDisplayNone() { let styleTag = document.createElement('style'); styleTag.textContent = '.ContextMenu-wrapper { display: none; }'; styleTag.id = 'addCustomCss1'; document.head.appendChild(styleTag); } function ContextMenuRemoveCustomCss() { let styleTag = document.getElementById('addCustomCss1'); if (styleTag != null){ styleTag.remove(); } let contextMenuElm = document.querySelector(".ContextMenu-wrapper") if (contextMenuElm) { contextMenuElm.click(); } } function SetDoubleTapCallback(targetElement, callback) { let tapCount = 0; targetElement.addEventListener( "touchstart", (e) => { // シングルタップの場合 if( !tapCount ) { // タップ回数を増加 ++tapCount ; // 350ミリ秒だけ、タップ回数を維持 setTimeout( () => { tapCount = 0 ; }, 350 ) ; //console.log("シングルタップ"); } else { // ダブルタップの場合 // ビューポートの変更(ズーム)を防止 e.preventDefault() ; // ダブルタップイベントの処理内容 //console.log( "ダブルタップに成功しました!!" ) ; callback(); // タップ回数をリセット tapCount = 0 ; } }); } function SetTapLongPressCallback(targetElement, callbackOn, callbackOff) { const kLongPressTime = 400; let tapCount = 0; let longPressTimerId = 0; let longPressOn = false; targetElement.addEventListener( "touchstart", (e) => { if (longPressTimerId != 0) { clearTimeout(longPressTimerId); longPressTimerId = 0; } longPressOn = false; longPressTimerId = setTimeout(() => { // ロングプレスされた場合 //console.log("LongPress!"); longPressOn = true; callbackOn(); }, kLongPressTime); }); targetElement.addEventListener( "touchend", (e) => { if (longPressTimerId != 0) { clearTimeout(longPressTimerId); longPressTimerId = 0; } if (longPressOn) { longPressOn = false; // ロングプレス終了 //console.log("LongPress off"); // メニューが表示されてしまうのを防ぐ ContextMenuDisplayNone(); setTimeout(() => { ContextMenuRemoveCustomCss(); }, 50); callbackOff(); } }); } function ChangePlaybackRate(rete) { const playbackMap = { "2": 1, "1.5": 3, "1": 5, } const rateIndex = playbackMap[rete]; if (rateIndex == undefined) { return ; } //console.log('playrate: ' + rete); // メニューが一瞬表示されてしまうのを防ぐ let videoOverlayElm = document.querySelector(".VideoOverlayContainer"); videoOverlayElm.style.display = "none"; setTimeout(() => { videoOverlayElm.style.display = null; }, 50); // 再生速度 setTimeout((rateIndex)=>{ document.querySelector("button.ActionButton.PlaybackRateButton").click(); setTimeout((rateIndex)=>{ document.querySelector(`div.PlaybackRateMenu-contents > div:nth-child(${rateIndex})`).click(); }, 0, rateIndex); }, 0, rateIndex); } let videoConteiner = document.querySelector("div.InView.VideoContainer") if (videoConteiner) { { const createElement = '<div id="video_backward"></div>'; // 最初の子要素として追加 videoConteiner.insertAdjacentHTML('afterbegin', createElement); let video_backward = document.getElementById("video_backward"); video_backward.style.cssText= ` width: 33%; height: 33%; z-index: 10; background: transparent; position: absolute; bottom: 0; `; SetDoubleTapCallback(video_backward, ()=> { // 戻し document.querySelector("button.ActionButton.ControllerButton.PlayerSeekBackwardButton").click(); }); } { const createElement = '<div id="video_forward"></div>'; // 最初の子要素として追加 videoConteiner.insertAdjacentHTML('afterbegin', createElement); let video_forward = document.getElementById("video_forward"); video_forward.style.cssText= ` width: 33%; height: 33%; z-index: 10; background: transparent; position: absolute; bottom: 0; margin: 0 auto; right: 0; `; SetDoubleTapCallback(video_forward, ()=> { // 戻し document.querySelector("button.ActionButton.ControllerButton.PlayerSeekForwardButton").click(); }); } { const createElement = '<div id="playbackrate_shortcut"> <div id="playbackrate_200_100_toggle"></div><div id="playbackrate_150_100_toggle"></div> </div>'; // 最初の子要素として追加 videoConteiner.insertAdjacentHTML('afterbegin', createElement); let playbackrate_shortcut = document.getElementById("playbackrate_shortcut"); playbackrate_shortcut.style.cssText= ` width: 33%; height: 50%; z-index: 10; background: transparent; position: absolute; right: 0; `; let playbackrate_200_100_toggle = document.getElementById("playbackrate_200_100_toggle"); playbackrate_200_100_toggle.style.cssText= ` width: 100%; height: 50%; `; SetDoubleTapCallback(playbackrate_200_100_toggle, () => { let videoPlayer = document.querySelector("#MainVideoPlayer > video"); if (videoPlayer.playbackRate == 2) { ChangePlaybackRate("1"); } else { ChangePlaybackRate("2"); } }); SetTapLongPressCallback(playbackrate_200_100_toggle,()=> { // longpress on ChangePlaybackRate("2"); }, ()=> { // longpress off ChangePlaybackRate("1"); }); let playbackrate_150_100_toggle = document.getElementById("playbackrate_150_100_toggle"); playbackrate_150_100_toggle.style.cssText= ` width: 100%; height: 50%; `; SetDoubleTapCallback(playbackrate_150_100_toggle, () => { let videoPlayer = document.querySelector("#MainVideoPlayer > video"); if (videoPlayer.playbackRate == 1.5) { ChangePlaybackRate("1"); } else { ChangePlaybackRate("1.5"); } }); SetTapLongPressCallback(playbackrate_150_100_toggle,()=> { // longpress on ChangePlaybackRate("1.5"); }, ()=> { // longpress off ChangePlaybackRate("1"); }); } } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址