Skip to content

Instantly share code, notes, and snippets.

@kamikat
Last active August 29, 2015 14:01
Show Gist options
  • Save kamikat/06ce0bab4cd92d889137 to your computer and use it in GitHub Desktop.
Save kamikat/06ce0bab4cd92d889137 to your computer and use it in GitHub Desktop.
Userscript for NICONICO(GINZA): add download link and axel download command generator after video title
// ==UserScript==
// @name Smile Download
// @namespace https://kirisetsz.github.io/
// @version 0.1.1
// @description Download video from Niconico (GINZA)
// @match http://www.nicovideo.jp/watch/*
// @copyright 2014, kirisetsz
// ==/UserScript==
var smile = function () {
var title = document.getElementsByClassName("videoHeaderTitle")[0];
var name = title.innerHTML;
var id = location.href.replace(/http.*?watch\/([^?]*)(\?.*)?$/g,"$1");
$.getJSON("http://www.nicovideo.jp/watch/" + id + "?mode=normal&playlist_token=" + require("WatchApp").ns('init').WatchInitializer.watchAPILoader.playlistToken,
function (json) {
var flv = unescape(/url\=(.*?)\&/.exec(decodeURIComponent(json.flashvars.flvInfo))[1]);
title.innerHTML = name + '<a href="' + flv + '" download="' + name + '.mp4">ヽ(•̀ω•́ )ゝ</a><a id="dcmd" href="#">✧</a>';
document.getElementById('dcmd').addEventListener('click', function (e) {
window.prompt('Download Command', 'axel -a -n3 -H \'Cookie: ' + document.cookie + '\' -o \'' + name + '.mp4\' ' + flv + '\n');
return e.preventDefault();
});
});
};
window.addEventListener('load', smile, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment