Greasy Fork

Greasy Fork is available in English.

네이버 블로그 모먼트 다운로더

네이버 블로그 모먼트 영상을 다운로드 합니다.

当前为 2021-07-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @namespace    https://tampermonkey.myso.kr/
// @name         네이버 블로그 모먼트 다운로더
// @description  네이버 블로그 모먼트 영상을 다운로드 합니다.
// @copyright    2021, myso (https://tampermonkey.myso.kr)
// @license      Apache-2.0
// @version      1.0.6
// @author       Won Choi
// @connect      naver.com
// @match        *://m.blog.naver.com/*/moment/*
// @grant        GM_addStyle
// @grant        GM_xmlhttpRequest
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-app.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-add-style.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-add-script.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-xmlhttp-request-async.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-xmlhttp-request-cors.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/vendor/gm-xmlhttp-request-hook.js
// @require      https://cdn.jsdelivr.net/npm/[email protected]/assets/donation.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.7.2/bluebird.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/downloadjs/1.4.8/download.min.js
// ==/UserScript==

// ==OpenUserJS==
// @author myso
// ==/OpenUserJS==
(function() {
  const cache = {};
  GM_donation('#root', 0);
  GM_addStyle(`
[class^="Footer_wrap__"] { bottom: calc(env(safe-area-inset-bottom) + 112px); }
[class^="MoreInfoLayer_fold__"] { bottom: calc(env(safe-area-inset-bottom) + 108px); }
[class^="SeekingBar_wrap__"] { bottom: calc(env(safe-area-inset-bottom) + 50px); }

.moment-download { position: fixed; z-index: 100000000; left: 0; right: 0; top: auto; bottom: 0; margin: auto; width: 100%; padding: 15px; background: #000; color: #fff; }
  `)
  GM_xmlhttpRequestHook((data, origin) => {
      const { type, target, detail } = data; if(!type || !target || !detail) { return origin; }
      const is_xhrload = type == 'xhrload';
      const is_moment_detail = target.startsWith('https://api-moment.blog.naver.com/blogs/') && target.includes('/momentPlayInfo/');
      if(is_xhrload && is_moment_detail) { cache.data = detail.responseJson; }
      return origin;
  });
  const button = document.querySelector('.moment-download') || document.createElement('button');
  button.classList.add('moment-download');
  button.textContent = '다운로드';
  button.onclick = async (e) => {
      if(!cache.data) return alert('통신 오류가 발생하였습니다. 새로고침 후 다시 시도해주세요.');
      const items = _.get(cache.data, 'result.playInfo', []);
      await Promise.map(items, async (item, offset) => {
          const videos = _.get(item, 'videos.list', []);
          const video = _.maxBy(videos, 'size');
          if(!video) return alert('통신 오류가 발생하였습니다. 새로고침 후 다시 시도해주세요.');
          const { encodingOption, source } = video;
          const prefix_a = _.get(item, 'meta.user.id', 'unknown');
          const prefix_b = _.get(item, 'tId', 'unknown');
          const filename = `moment-${prefix_a}-${prefix_b}-${encodingOption.name}-${offset}.mp4`;
          download(source, filename, 'video/mp4');
      });
  }
  document.querySelector('#root').appendChild(button);
})();