// ==UserScript== // @name ニコニコ動画 動画視聴モード // @description 動画視聴時の補助機能詰め合わせ。 // @include http://www.nicovideo.jp/watch/* // @include https://www.nicovideo.jp/watch/* // @author toshi (https://github.com/k08045kk) // @license MIT License // @see https://opensource.org/licenses/MIT // @version 9.1 // @see 1 - 2018/01/01 - 初版 // @see 2 - 2018/05/07 - 機能を統合「ニコニコ動画のHTML5/Flash版で視聴するバーを移動」 // @see 3 - 2018/07/07 - 動画部のクリックで再生/停止制御を追加 // @see 3.1 - 2018/10/21 - https対応 // @see 4 - 2019/06/11 - 動画部のクリックで再生/停止制御を再度対応 // @see 5 - 2019/06/20 - プレイヤー内のポップアップメニューと最上部バーの被り対応 // @see 6 - 2019/10/04 - 動画のクリックで再生/停止が動作しなくなっていた(クリック領域を変更) // @see 6.1 - 2019/10/24 - プレイヤー上部の空間を減らす // @see 7 - 2020/07/08 - ニコニコ動画バージョンアップ対応 // @see 8 - 2020/10/31 - 誘導があまりにも邪魔なため、しかたなく非表示 // @see 9 - 2020/12/03 - シリーズリンクのパラメータを削除(訪問済みリンク判定しやすくする) // @see 9.1 - 2020/12/03 - fix メニューバークリックのモード切換え処理が動作していなかった // @see https://www.bugbugnow.net/2018/01/niconicovideomode.html // @see https://greasyfork.org/ja/scripts/367647 // @grant none // @namespace https://www.bugbugnow.net/ // @downloadURL none // ==/UserScript== // HTML5とFlash切換えバーをページ下部へ移動する。 (function () { // Flash版 var flash = document.querySelector('.html5_message'); var footer = document.querySelector('#footer'); if (flash && footer) { flash.style.margin = '0px'; footer.insertAdjacentElement('beforebegin', flash); } // HTML5版 var html = document.querySelector('.SwitchToFlashLead'); var footer = document.querySelector('.FooterContainer'); if (html && footer) { footer.style.marginTop = '0px'; footer.insertAdjacentElement('beforebegin', html); } })(); // 動画視聴モードへ移行 // 上部のメニューバーをクリックで通常/動画モード切換える (function () { const toggleVideoMode = () => { var player = null; if ((player=document.querySelector('#playerContainerWrapper')) != null) { // Flash版 if (document.querySelector('.videoMode') == null) { document.querySelector('#content').insertAdjacentElement('afterbegin', player); player.classList.add('videoMode'); } else { document.querySelector('#enquete-placeholder').insertAdjacentElement('beforebegin', player); player.classList.remove('videoMode'); } } else if ((player=document.querySelector('.MainContainer')) != null) { // HTML5版 if (document.querySelector('.videoMode') == null) { document.querySelector('.WatchAppContainer-main').insertAdjacentElement('afterbegin', player); player.classList.add('videoMode'); player.style.marginTop = '32px'; } else { document.querySelector('.HeaderContainer').insertAdjacentElement('afterend', player); player.classList.remove('videoMode'); player.style.marginTop = ''; } } }; window.addEventListener("click", function(event) { var header = document.querySelector('#CommonHeader > div > div > div'); if (event.target === header) { toggleVideoMode(); } }); // 動画モードへ移行 toggleVideoMode(); })(); // 動画のクリックで再生/停止 (function () { window.addEventListener("load", function(){ var player = document.querySelector('.InView.VideoContainer'); if (player != null) { player.addEventListener('click', function() { var play = document.querySelector('.ActionButton.ControllerButton.PlayerPlayButton'); var stop = document.querySelector('.ActionButton.ControllerButton.PlayerPauseButton'); if (play != null) { play.click(); } else if (stop != null) { stop.click(); } }); } }); })(); // 誘導を非表示 (function () { function addLocalStyle(text) { var style = document.createElement('style'); style.textContent = text; document.head.appendChild(style); } window.addEventListener("load", function(){ // 動画内ポップアップを非表示 addLocalStyle(".PreVideoStartPremiumLinkOnEconomyTimeContainer { display:none; }"); }); // 補足:本処理は、ユーザースタイルとして独立させるほうが正しい })(); // シリーズリンクのパラメータを削除(ブラウザが訪問済みリンク判定しやすくする) (function () { window.addEventListener("load", function(){ document.querySelectorAll('a.RouterLink').forEach(function(v) { v.href = v.href.split('?')[0]; }); }); })();