Skip to content

Commit

Permalink
Support TV shows in Trakt
Browse files Browse the repository at this point in the history
Ref #14
  • Loading branch information
SpaceK33z committed Dec 18, 2016
1 parent 0cc67f6 commit ac49165
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/trakt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ function isMoviePage() {
return true;
}

function isMoviePageReady() {
function isShowPage() {
const path = window.location.pathname;
if (!path.startsWith('/shows/')) {
return false;
}
// TODO: e.g. /movies/trending is not really a movie page...
return true;
}

Expand All @@ -20,9 +25,9 @@ function getImdbId() {
}

function init() {
if(isMoviePage()) {
if(isMoviePage() || isShowPage()) {
wait(() => document.querySelector('#info-wrapper ul.external'), () => {
initPlexThingy();
initPlexThingy(isMoviePage() ? 'movie' : 'show');
});
}
}
Expand All @@ -43,7 +48,7 @@ function renderPlexButton() {
return el;
}

function initPlexThingy() {
function initPlexThingy(type) {
const $button = renderPlexButton();
if (!$button) {
return;
Expand All @@ -58,7 +63,7 @@ function initPlexThingy() {
const year = parseInt($year.textContent.trim());
const imdbId = getImdbId();

handlePlex(config, { title, year, button: $button, imdbId });
handlePlex(config, { type, title, year, button: $button, imdbId });
}

let config;
Expand Down

0 comments on commit ac49165

Please sign in to comment.