forked from ywzhaiqi/userscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trakt.tv_个人辅助脚本.user.js
129 lines (118 loc) · 3.38 KB
/
trakt.tv_个人辅助脚本.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// ==UserScript==
// @name trakt.tv 个人辅助脚本
// @namespace https://github.com/ywzhaiqi
// @include http://trakt.tv/calendar/my-shows*
// @include https://trakt.tv/calendar/my-shows*
// @version 1.1
// @grant GM_getValue
// @grant GM_setValue
// @require http://cdn.staticfile.org/zepto/1.1.4/zepto.min.js
// ==/UserScript==
// 优先的类别
var enableType = 'yyets';
// 无法在线播放的规则
var rules = {
'criminal minds': {
name: '犯罪心理',
// 存在在线播放的地址
yyets: 'http://www.yyets.com/resource/11003',
yyxz: 'http://www.yayaxz.com/resource/11003'
},
'hawaii five0': {
name: '天堂执法者',
yyets: 'http://www.yyets.com/resource/10998',
yyxz: 'http://www.yayaxz.com/resource/10998'
},
'castle 2009': {
name: '灵书妙探',
yyets: 'http://www.yyets.com/resource/10996',
yyxz: 'http://www.yayaxz.com/resource/10996',
},
'the big bang theory': {
name: '生活大爆炸',
yyets: 'http://www.yyets.com/resource/11005',
yyxz: 'http://www.yayaxz.com/resource/11005'
},
'the voice us': {
name: '美国之声',
},
'marvels agents of shield': {
name: '神盾局特工',
},
'arrow': {
name: '绿箭侠'
},
'the amazing race': {
name: '极速前进',
sohu: 'http://tv.sohu.com/item/MTE5NDU1NA==.html',
},
'ncis': {
name: '海军罪案调查处',
yyets: 'http://www.yyets.com/resource/11001',
yyxz: 'http://www.yayaxz.com/resource/11001'
},
'2 broke girls': {
name: '破产姐妹'
},
'elementary': {
name: '基本演绎法'
},
'white collar': {
name: '妙警贼探',
},
'one piece': {
name: '海贼王',
},
'the mentalist': {
name: '超感神探',
qiyi: 'http://www.iqiyi.com/a_19rrhc4811.html',
// qq: 'http://v.qq.com/search.html?ms_key=超感神探',
}
};
var ns = {
init: function() {
ns.run();
},
run: function() {
$('a[href^="/show/"]').each(ns.addLink);
},
addLink: function(i, link) {
var $link = $(link);
url = $link.attr('href');
var match = url.match(/\/show\/(.*?)\/season/);
if (!match) {
console.error('无法从链接中找到电视剧的名称:%s', url);
return;
}
var name = match[1].replace(/-/g, ' ');
var info = ns.getInfo(name);
$('<a>').attr({
href: info.url,
title: info.title,
target: '_blank'
}).text(info.text).appendTo($link.prev());
},
getInfo: function(name) {
var url, text, title;
var rule = rules[name];
if (rule) {
name = rule.name;
// 如果有优先的先选择优先的,否则选择第一个
var keys = Object.keys(rule);
keys.splice(keys.indexOf('name'), 1);
var key = (keys.indexOf(enableType) != -1) ? enableType : keys[0];
url = rule[key];
text = key;
title = url;
}
if (!url) {
url = 'http://www.soku.com/v?keyword=' + name;
}
return {
url: url,
text: text || 'sk',
title: title || '搜库'
};
}
};
ns.init();