-
Notifications
You must be signed in to change notification settings - Fork 1
/
dailymotion_subtitles.js
46 lines (42 loc) · 1.34 KB
/
dailymotion_subtitles.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
/* jshint global yt:false */
(function(){
'use strict';
var flashvars,
subtitles,
parseTree = function(element, value) {
var result;
if (typeof(element) == 'object' ) {
for (var i in element) {
if (i == value) {
result = element[i];
break;
} else {
var tmp = parseTree(element[i], value);
if (typeof(tmp) != 'undefined') {
result = tmp;
break;
}
}
}
}
return result;
}
$.each($('#container_player_main').find('param[name=flashvars]').val().split('&'),
function(index, value){
if (value.substr(0,8)=='sequence'){
value = unescape(value).substr(9);
flashvars=JSON.parse(value);
}
});
subtitles = parseTree(flashvars, 'availableSubtitles');
var s = '';
var list = [];
for (var type in subtitles) {
list.push(subtitles[type]);
s += list.length +' => '+type+'\n';
}
var r = parseInt(window.prompt(s),10)-1;
if (r < list.length) {
window.location.assign(list[r]);
}
})();