MyNdownloader

はいいいえ

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MyNdownloader
// @namespace    tests
// @version      0.2
// @description  はいいいえ
// @author       You
// @match          *://www.nicovideo.jp/*
// @match          *://ext.nicovideo.jp/
// @match          *://ext.nicovideo.jp/#*
// @match          *://blog.nicovideo.jp/*
// @match          *://ch.nicovideo.jp/*
// @match          *://com.nicovideo.jp/*
// @match          *://commons.nicovideo.jp/*
// @match          *://dic.nicovideo.jp/*
// @match          *://ex.nicovideo.jp/*
// @match          *://info.nicovideo.jp/*
// @match          *://search.nicovideo.jp/*
// @match          *://uad.nicovideo.jp/*
// @match          *://api.search.nicovideo.jp/*
// @match          *://*.nicovideo.jp/smile*
// @match          *://site.nicovideo.jp/*
// @exclude        *://ads.nicovideo.jp/*
// @exclude        *://www.upload.nicovideo.jp/*
// @exclude        *://www.nicovideo.jp/watch/*?edit=*
// @exclude        *://ch.nicovideo.jp/tool/*
// @exclude        *://flapi.nicovideo.jp/*
// @exclude        *://dic.nicovideo.jp/p/*
// @grant       GM.download
// @grant       GM_download
// @grant       GM.registerMenuCommand
// @grant       GM_registerMenuCommand
// ==/UserScript==




(function () {
	'use strict';

	let keyDownloadMov = 'r';
	let keyDownloadMylist = 'a';


	var isBusy = false;


	GM.registerMenuCommand(_('動画をダウンロードする'), saveMov, keyDownloadMov);

	GM.registerMenuCommand(_('動画をダウンロードする(マイリスト再生)'), async function () {
		var oldSrc = '';
		setInterval(function () {
			try {
				let src = document.querySelector('#ZenzaWatchVideoPlayerContainer > video').src;
				if (oldSrc !== src) {
					oldSrc = src;
					saveMov();
				}

			} catch (e) { clearInterval(); }
		}, 1000);
	}, keyDownloadMylist);


	async function saveMov() {
		try {
			let src = document.querySelector('#ZenzaWatchVideoPlayerContainer > video').src;

			var author = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-dmcAvailable.is-dmcPlaying.showVideoControlBar.showVideoHeaderPanel.is-open > div.zenzaWatchVideoInfoPanel.show.userVideo > div.tabs.videoInfoTab.activeTab > div > div.zenzaWatchVideoInfoPanelContent > div.videoOwnerInfoContainer > span > span');
			if (!author) author = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-dmcAvailable.is-dmcPlaying > div.zenzaWatchVideoInfoPanel.show.userVideo > div.tabs.videoInfoTab.activeTab > div > div.zenzaWatchVideoInfoPanelContent > div.videoOwnerInfoContainer > span > span');
			if (!author) author = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-playing > div.zenzaWatchVideoInfoPanel.show.userVideo > div.tabs.videoInfoTab.activeTab > div > div.zenzaWatchVideoInfoPanelContent > div.videoOwnerInfoContainer > span > span');
			if (!author) author = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-dmcAvailable.is-dmcPlaying.is-pausing > div.zenzaWatchVideoInfoPanel.show.userVideo > div.tabs.videoInfoTab.activeTab > div > div.zenzaWatchVideoInfoPanelContent > div.videoOwnerInfoContainer > span > span');
			author = author.innerText;
			author = author.slice(0, author.length - 3);


			var title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-dmcAvailable.is-dmcPlaying.showVideoControlBar.showVideoHeaderPanel.is-open > div.zenzaWatchVideoHeaderPanel.show.userVideo > h2 > span');
			if (!title) title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-dmcAvailable.is-dmcPlaying.is-playing > div.zenzaWatchVideoHeaderPanel.show.has-Parent.userVideo > h2 > span');
			if (!title) title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-playing > div.zenzaWatchVideoHeaderPanel.show.has-Parent.userVideo > h2 > span');
			if (!title) title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-dmcAvailable.is-dmcPlaying.is-playing > div.zenzaWatchVideoHeaderPanel.show.userVideo > h2 > span');
			if (!title) title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-dmcAvailable.is-dmcPlaying.is-pausing > div.zenzaWatchVideoHeaderPanel.show.userVideo > h2 > span');
			if (!title) title = document.querySelector('#zenzaVideoPlayerDialog > div > div.zenzaPlayerContainer.is-showComment.is-regularUser.is-open.is-playing > div.zenzaWatchVideoHeaderPanel.show.userVideo > h2 > span');
            title = title.innerText;

			GM_download(src, `${title}[${author}].mp4`);
		} catch (e) { alert('ダウンロードできませんでした。'); throw new Error(e.name + ': ' + e.message); }
	}


	//console.log('called');
	//GM_download('https://maoudamashii.jokersounds.com/music/se/mp3/se_maoudamashii_se_syber05.mp3', 'test.mp3');
})();