Skip to content

Commit

Permalink
TVMaze with addic7ed flavor
Browse files Browse the repository at this point in the history
Adds button below the "mark as watched/watched" one that opens correct
addic7ed page for that specific episode.
  • Loading branch information
vBm committed Oct 8, 2015
1 parent 03781c1 commit e6a5059
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions addic7ed.tvmaze.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ==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.1
// @date 08/10/2015
// @grant none
// ==/UserScript==

var showInfoName = $('div#general-info-panel').find('p').first().find('a').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)'
};

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',
target: '_blank',
style: 'margin-top: 3px'
}).text(' Addic7ed subs').click(
function() {
window.open(subtitlesUrl);
})
);

$('<i class="fa fa-download"></i>').prependTo('.addic7ed');

0 comments on commit e6a5059

Please sign in to comment.