Warning: fopen(/www/sites/update.greasyfork.icu/index/store/forever/485178e437030042081c5ff003d28789.js): failed to open stream: No space left on device in /www/sites/update.greasyfork.icu/index/scriptControl.php on line 65
// ==UserScript==
// @name ニコニコ動画 動画視聴モード
// @description 動画視聴時の補助機能詰め合わせ。
// @match *://www.nicovideo.jp/watch/*
// @author toshi (https://github.com/k08045kk)
// @license MIT License
// @see https://opensource.org/licenses/MIT
// @version 11
// @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 9.2 - 2020/12/04 - fix 内部的なページ遷移後にシリーズリンクのパラメータを削除しない
// @see 9.4 - 2020/12/07 - 内部ページ移動時にページ最上部へ移動
// @see 10 - 2021/01/06 - Flash処理を削除
// @see 11 - 2021/01/13 - 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==
// 動画視聴モードへ移行
// 上部のメニューバーをクリックで通常/動画モード切換える
(function () {
const toggleVideoMode = function() {
let player = document.querySelector('.MainContainer');
if (player) {
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) {
const header = document.querySelector('#CommonHeader > div > div');
if (header.contains(event.target) || header == event.target) {
toggleVideoMode();
}
});
// 動画モードへ移行
toggleVideoMode();
})();
// 動画のクリックで再生/停止
(function () {
window.addEventListener('load', function(){
const player = document.querySelector('.InView.VideoContainer');
if (player != null) {
player.addEventListener('click', function() {
const play = document.querySelector('.ActionButton.ControllerButton.PlayerPlayButton');
const stop = document.querySelector('.ActionButton.ControllerButton.PlayerPauseButton');
if (play != null) {
play.click();
} else if (stop != null) {
stop.click();
}
});
}
});
})();
// 誘導を非表示
(function () {
function addLocalStyle(text) {
const style = document.createElement('style');
style.textContent = text;
document.head.appendChild(style);
};
window.addEventListener('load', function() {
// 動画内ポップアップを非表示
addLocalStyle('.PreVideoStartPremiumLinkOnEconomyTimeContainer { display:none; }');
});
// 補足:本処理は、ユーザースタイルとして独立させるほうが正しい
})();
// シリーズリンクのパラメータを削除(ブラウザが訪問済みリンク判定しやすくする)
(function () {
const target = document.querySelector('.VideoDescription-series');
const config = {attributes:true, childList:true, subtree:true};
const callback = function(mutationsList, observer) {
document.querySelectorAll('a.RouterLink').forEach(function(v) {
if (v.href.indexOf('?') != -1) {
v.href = v.href.split('?')[0];
}
});
};
new MutationObserver(callback).observe(target, config);
window.addEventListener('load', callback);
})();
// 内部ページ移動時にページ最上部へ移動
(function () {
document.body.addEventListener('click', function(event) {
if (event && event.target && event.target.href) {
if (event.target.href.indexOf('://www.nicovideo.jp/watch/') != -1) {
window.scroll({top:0, behavior:'smooth'});
}
}
});
})();