forked from segabito/ZenzaWatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WatchDump.user.js
69 lines (58 loc) · 2.04 KB
/
WatchDump.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name WatchDump
// @namespace https://github.com/segabito/
// @description 動画データをコンソールにダンプする. デバッグ用のヘルパー
// @include http://*.nicovideo.jp/watch/*
// @version 0.1
// @grant none
// ==/UserScript==
(function() {
var monkey = (function() {
'use strict';
class Util {
static parseQuery(query) {
const result = {};
query.split('&').forEach(item => {
const sp = item.split('=');
const key = decodeURIComponent(sp[0]);
const val = decodeURIComponent(sp.slice(1).join('='));
result[key] = val;
});
return result;
}
}
(function() {
const container = document.getElementById('watchAPIDataContainer');
if (!container) { return; }
console.info('%cver GINZA', 'font-size: 150%;');
const data = JSON.parse(container.textContent);
const flvInfo = Util.parseQuery(decodeURIComponent(data.flashvars.flvInfo));
const dmcInfo = JSON.parse(decodeURIComponent(data.flashvars.dmcInfo || '{}'));
window.watchData = {
data,
flvInfo,
dmcInfo
};
console.log('watchData:', window.watchData);
})();
(function() {
const container = document.getElementById('js-initial-watch-data');
if (!container) { return; }
console.info('%cver HTML5', 'font-size: 150%;');
const data = JSON.parse(container.getAttribute('data-api-data'));
const env = JSON.parse(document.getElementById('js-initial-watch-data').getAttribute('data-environment'));
window.watchData = {
data,
env,
dmcInfo: data.video.dmcInfo
};
console.log('watchData:', window.watchData);
})();
});
var script = document.createElement('script');
script.id = 'WatchDumpLoader';
script.setAttribute('type', 'text/javascript');
script.setAttribute('charset', 'UTF-8');
script.appendChild(document.createTextNode('(' + monkey + ')()'));
document.body.appendChild(script);
})();