您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
下载N站视频 | Download video from nicovideo.jp
当前为
// ==UserScript== // @name Nico dl // @namespace http://tampermonkey.net/ // @version 0.1 // @description 下载N站视频 | Download video from nicovideo.jp // @author ctrn43062 // @include *//www.nicovideo.jp/watch/sm* // @icon https://www.google.com/s2/favicons?domain=nicovideo.jp // @grant none // @license MIT // ==/UserScript== const ITEM_KEY = 'DMCSource.isHLSDisabled'; const DOWNLOAD_SVG = `<svg version="1.1"id="Capa_1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"x="0px"y="0px"viewBox="0 0 330 330"style="enable-background:new 0 0 330 330;"xml:space="preserve"><g><path d="M165,0C74.019,0,0,74.018,0,165c0,90.98,74.019,165,165,165s165-74.02,165-165C330,74.018,255.981,0,165,0z M165,300c-74.439,0-135-60.561-135-135S90.561,30,165,30s135,60.561,135,135S239.439,300,165,300z"/><path d="M211.667,127.121l-31.669,31.666V75c0-8.285-6.716-15-15-15c-8.284,0-15,6.715-15,15v83.787l-31.665-31.666c-5.857-5.857-15.355-5.857-21.213,0c-5.858,5.859-5.858,15.355,0,21.213l57.271,57.271c2.929,2.93,6.768,4.395,10.606,4.395c3.838,0,7.678-1.465,10.607-4.393l57.275-57.271c5.857-5.857,5.858-15.355,0.001-21.215C227.021,121.264,217.524,121.264,211.667,127.121z"/><path d="M195,240h-60c-8.284,0-15,6.715-15,15c0,8.283,6.716,15,15,15h60c8.284,0,15-6.717,15-15C210,246.715,203.284,240,195,240z"/></svg>` function createDownloadButton() { const playbackRateButton = document.querySelector('.ActionButton.PlaybackRateButton'); const wrapper = playbackRateButton.parentElement; const downloadButton = document.createElement('button'); downloadButton.innerHTML = DOWNLOAD_SVG; downloadButton.className = 'ActionButton ControllerButton PlayerRepeatOnButton'; downloadButton.setAttribute('disabled', true); downloadButton.setAttribute('data-title', '下载视频'); wrapper.insertBefore(downloadButton, playbackRateButton); return { setSrc: function(src) { downloadButton.removeAttribute('disabled'); downloadButton.onclick = function() { window.open(src) }; }, disable: function() { downloadButton.setAttribute('disabled', true); } } } (function() { 'use strict'; const isHttp = localStorage.getItem(ITEM_KEY); if (isHttp === null || isHttp === 'false') { localStorage.setItem(ITEM_KEY, 'true'); location.reload(); } const downloadButton = createDownloadButton(); const observer = new MutationObserver(mutationsList => { for (let mutation of mutationsList) { const target = mutation.target; if (mutation.attributeName === 'src') { if (target.src) { downloadButton.setSrc(target.src); } else { downloadButton.disable(); } } } }); const video = document.querySelector('#MainVideoPlayer > video'); observer.observe(video, { attributes: true }); })();