-
Notifications
You must be signed in to change notification settings - Fork 1
/
addic7ed.tvmaze.user.js
55 lines (47 loc) · 1.7 KB
/
addic7ed.tvmaze.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
// ==UserScript==
// @name TVMaze Subtitles
// @namespace tvmaze
// @description Link addic7ed subs
// @icon http://tvmazecdn.com/images/favico/favicon.ico
// @author vBm <[email protected]>
// @oujs:author vBm
// @license The MIT License (MIT)
// @supportURL https://github.com/vBm/snippets/issues
// @include http://www.tvmaze.com/episodes/*
// @version 0.3
// @date 02/07/2016
// @grant none
// ==/UserScript==
var showInfoName = $('div#general-info-panel').find('p').first().find('a').first().text();
var showInfoRegex = /Number\:.*(\d+).*\n\s+Episode.(\d+)/g;
var match = showInfoRegex.exec($('div#general-info-panel p')[0].innerHTML);
var showInfoSeason = match[1];
var showInfoEpisode = match[2];
var showInfoEpisodeName = $('header h1').text();
// Due to different names either one of pages use we have to create an array to circumvent around it.
var addic7ed = {
'Legends': 'Legends_(2014)',
'The Flash': 'The Flash (2014)',
'House Of Cards': 'House_of_Cards_(2013)',
'Secrets & Lies': 'Secrets and Lies',
'Ash vs Evil Dead': 'Ash vs. Evil Dead'
};
showInfoName = addic7ed[showInfoName] || showInfoName;
var subtitlesUrl = 'http://www.addic7ed.com/serie/'+showInfoName+'/'+showInfoSeason+'/'+showInfoEpisode+'/'+showInfoEpisodeName;
console.log(subtitlesUrl);
$('#main-img').append(
$('<a>').attr({
id: 'watching',
class: 'radius small button secondary addic7ed js-needlogin',
target: '_blank',
}).css({
float: 'right',
width: '100%',
marginTop: '3px'
}).text(' Addic7ed subs').click(
function() {
window.open(subtitlesUrl);
}
)
);
$('<i class="fa fa-download"></i>').prependTo('.addic7ed');