Skip to content

Commit

Permalink
Updated to 1.0.2.0
Browse files Browse the repository at this point in the history
Added Amazon, Verizon, and Vudu. Also fixed a few icons, and scripts.
  • Loading branch information
Ephellon committed May 20, 2018
1 parent fe38e6e commit 250dbbe
Show file tree
Hide file tree
Showing 30 changed files with 489 additions and 31 deletions.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.crx
Binary file not shown.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.zip
Binary file not shown.
42 changes: 42 additions & 0 deletions src/deps/amazon/cs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.web-to-plex-button {
margin-right: 8px;
color: #fff!important;
margin-bottom: 8px!important;
line-height: 2!important;
}

.web-to-plex-button--downloader {
background-color: #f45a26!important;
}

.web-to-plex-button--downloader:hover {
background-color: #f67e56!important;
}

.web-to-plex-button--found {
background-color: #ca7c1f!important;
}

.web-to-plex-button--found:hover {
background-color: #f8c022!important;
}

.web-to-plex-notification {
cursor: pointer;
display: block;
position: fixed;
top: 80px;
left: 50%;
margin-left: -175px;
width: 350px;
background: #21262e;
color: #fff;
font-size: 20px;
padding: 10px;
border-radius: 4px;
z-index: 999000;
}

.web-to-plex-warning {
background: #fd6a00;
}
71 changes: 71 additions & 0 deletions src/deps/amazon/cs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* global findPlexMedia, parseOptions, modifyPlexButton */
function isMovie() {
return !isShow();
}

function isShow() {
return document.querySelector('[data-automation-id="num-of-seasons-badge"]');
}

function isPageReady() {
return document.querySelector('[data-automation-id="imdb-rating-badge"]');
}

async function init() {
if (isPageReady())
await initPlexThingy(isMovie()? 'movie': 'tv');
else
// This almost never happens, but sometimes the page is too slow so we need to wait a bit.
setTimeout(init, 1000);
}

function renderPlexButton($parent) {
if (!$parent) return;

let existingButton = document.querySelector('a.web-to-plex-button');
if (existingButton)
existingButton.remove();

let el = document.createElement('a');

el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button', 'av-button', 'av-button--default');

$parent.appendChild(el);
return el;
}

async function initPlexThingy(type) {
let $parent = document.querySelector('#dv-action-box .av-action-button-box'),
$button = renderPlexButton($parent);

if (!$button)
return;

let $title = document.querySelector('[data-automation-id="title"]'),
$year = document.querySelector('[data-automation-id="release-year-badge"]');

if (!$title)
return modifyPlexButton(
$button,
'error',
'Could not extract title from Amazon'
),
null;

let title = $title.textContent.replace(/\(.+?\)$/, '').trim(),
year = $year? $year.textContent.trim(): YEAR;

console.log({ title, year });

let Db = await getIDs({ title, year, APIType: type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
}

if (isMovie() || isShow()) {
parseOptions().then(async() => await init());
}
1 change: 0 additions & 1 deletion src/deps/fandango/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function renderPlexButton($parent) {
el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button', 'subnav__link');
el.style.display = 'none';

pa.appendChild(el);
$parent.insertBefore(pa, $parent.lastElementChild);
Expand Down
2 changes: 1 addition & 1 deletion src/deps/google/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async function initPlexThingy(type) {
$year = document.querySelector(`h1 ~ div span:${ type === 'movie'? 'first': 'last' }-of-type`);

if (!$title || !$year)
return modifyPlexButton($button, 'error', 'Could not extract ' + (!$title? 'title': 'year'));
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' } from Google`);

let title = $title.textContent.replace(/\(\s*(\d{4})\s*\).*?$/, '').trim(),
year = (RegExp.$1 || $year.textContent).replace(/^.*?(\d+)/, '$1').trim(),
Expand Down
1 change: 0 additions & 1 deletion src/deps/hulu/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function renderPlexButton($parent) {
el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button');
el.style.display = 'none';

$parent.insertBefore(ma, $parent.lastElementChild);
return el;
Expand Down
4 changes: 2 additions & 2 deletions src/deps/imdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function renderPlexButton($parent) {
el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button');
el.style.display = 'none';

$parent.appendChild(el);
return el;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ async function initPlexShow() {
dateMatch = date.match(/Series\s+(\d{4})/);

if (!$title || !dateMatch)
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' }`);
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' } from IMDb`);

let title = $title.textContent.trim(),
year = dateMatch[1],
Expand Down
1 change: 0 additions & 1 deletion src/deps/itunes/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function renderPlexButton($parent) {
el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button');
el.style.display = 'none';

$parent.insertBefore(el, $parent.querySelector('.view-in-itunes ~ *'));
return el;
Expand Down
3 changes: 1 addition & 2 deletions src/deps/metacritic/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function initPlexThingy(type) {
return console.log('failed'), modifyPlexButton(
$button,
'error',
'Could not extract title or year from Metacritic'
`Could not extract ${ !$title? 'title': 'year' } from Metacritic`
);

let title = $title.textContent.trim(),
Expand All @@ -53,7 +53,6 @@ function renderPlexButton() {

el.classList.add('web-to-plex-button');
el.title = 'Web to Plex+';

el.appendChild(ch);
$actions.appendChild(el);

Expand Down
3 changes: 2 additions & 1 deletion src/deps/movieo/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function initPlexThingy() {
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from Movieo'
`Could not extract ${ !$title? 'title': 'year' } from Movieo`
);

let title = $title.dataset.title.trim(),
Expand Down Expand Up @@ -78,6 +78,7 @@ function renderPlexButton() {
el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('button', 'comments-link', 'web-to-plex-button');

$actions.appendChild(el);
return el;
}
Expand Down
2 changes: 1 addition & 1 deletion src/deps/tmdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function initPlexThingy(type) {
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from Movieo'
`Could not extract ${ !$title? 'title': 'year' } from TheMovieDb`
);

let title = $title.textContent.trim(),
Expand Down
2 changes: 1 addition & 1 deletion src/deps/trakt/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function initPlexThingy(type) {
$year = document.querySelector('.mobile-title .year');

if (!$title || !$year)
return modifyPlexButton($button, 'error', 'Could not extract ' + (!$title? 'title': 'year'));
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' } from Trakt`);

let title = $title.textContent.replace(/(.+)(\d{4}).*?$/, '$1').trim(),
year = (RegExp.$2 || $year.textContent).trim(),
Expand Down
2 changes: 1 addition & 1 deletion src/deps/tvdb/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function initPlexThingy() {
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from TheTVDb'
`Could not extract ${ !$title? 'title': 'year' } from TheTVDb`
),
null;

Expand Down
2 changes: 1 addition & 1 deletion src/deps/tvmaze/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function initPlexThingy() {
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from TV Maze'
`Could not extract ${ !$title? 'title': 'year' } from TV Maze`
),
null;

Expand Down
39 changes: 39 additions & 0 deletions src/deps/verizon/cs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.web-to-plex-button--downloader {
border-color: #f45a26!important;
background: #f45a26!important;
color: #fff!important;
}

.web-to-plex-button--downloader:hover {
background: #f67e56!important;
}

.web-to-plex-button--found {
background: #e5a00d!important;
border-color: #e5a00d!important;
color: #fff!important;
}

.web-to-plex-button--found:hover {
background: #f9be03!important;
}

.web-to-plex-notification {
cursor: pointer;
display: block;
position: fixed;
top: 80px;
left: 50%;
margin-left: -175px;
width: 350px;
background: #21262e;
color: #fff;
font-size: 20px;
padding: 10px;
border-radius: 4px;
z-index: 999000;
}

.web-to-plex-warning {
background: #fd6a00;
}
66 changes: 66 additions & 0 deletions src/deps/verizon/cs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* global wait, modifyPlexButton, parseOptions, findPlexMedia */
function isMoviePage() {
return window.location.pathname.startsWith('/movie/');
}

function isShowPage() {
return window.location.pathname.startsWith('/series/');
}

function init() {
if (isMoviePage() || isShowPage()) {
wait(
() => document.querySelector('.container .btn-with-play'),
() => initPlexThingy(isMoviePage() ? 'movie' : 'tv')
);
}
}

function renderPlexButton() {
let $actions = document.querySelector('.container .content-holder');
if (!$actions)
return;

let existingButton = $actions.querySelector('a.web-to-plex-button');
if (existingButton)
return;

let el = document.createElement('a');

el.textContent = 'Web to Plex+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button', 'btn');
$actions.appendChild(el);

return el;
}

async function initPlexThingy(type) {
let $button = renderPlexButton();

if (!$button)
return;

let $title = document.querySelector('.copy > .title'),
$year = (type === 'movie')?
document.querySelector('.copy > .details'):
document.querySelector('.summary ~ .title ~ *');

if (!$title || !$year)
return modifyPlexButton($button, 'error', `Could not extract ${ !$title? 'title': 'year' } from Verizon`);

let title = $title.textContent.trim(),
year = $year.textContent.slice(0, 4).trim();

let Db = await getIDs({ title, year, APIType: type }),
IMDbID = Db.imdb,
TVDbID = Db.thetvdb;

findPlexMedia({ type, title, year, button: $button, IMDbID, TVDbID });
}

parseOptions().then(() => {
window.addEventListener('popstate', init);
window.addEventListener('pushstate-changed', init);
init();
});
2 changes: 1 addition & 1 deletion src/deps/vrv/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function initPlexThingy() {
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from VRV'
`Could not extract ${ !$title? 'title': 'year' } from VRV`
),
null;

Expand Down

0 comments on commit 250dbbe

Please sign in to comment.