Skip to content

Commit

Permalink
Updated to 1.2.1.0
Browse files Browse the repository at this point in the history
Added CouchPotato adn Rotten Tomatoes. Also made small fixes.
  • Loading branch information
Ephellon committed Jun 7, 2018
1 parent aa79f4a commit afdeb40
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 31 deletions.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.crx
Binary file not shown.
Binary file modified hhkmjeeccipbolailpomhjhmccnnjhkj.zip
Binary file not shown.
43 changes: 43 additions & 0 deletions src/deps/couchpotato/cs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.web-to-plex-button--downloader {
color: #f45a26!important;
}

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

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

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

#tt--0-0 {
color: #666!important;
}

#tt--0-0:hover {
color: #888!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;
}
72 changes: 72 additions & 0 deletions src/deps/couchpotato/cs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* global wait, modifyPlexButton, parseOptions, findPlexMedia */
function init() {
wait(
() => document.querySelector('.media-body .clearfix').children.length > 1,
() => initPlexThingy(isMovie()? 'movie': 'show')
);
}

function isMovie() {
return /^\/movies?\//.test(window.location.pathname);
}

function isShow() {
return /^\/shows?\//.test(window.location.pathname);
}

function initPlexThingy(type) {
let $button = renderPlexButton();
if (!$button)
return;

let $title = document.querySelector('[itemprop="description"]'),
$date = $title.previousElementSibling;

if (!$title || !$date)
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from CouchPotato'
);

let title = $title.textContent.trim(),
year = $date.textContent.trim(),
IMDbID = getIMDbID();

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

function renderPlexButton() {
let $actions = document.querySelector('[href*="imdb.com/title/tt"]').parentElement;
if (!$actions)
return;

let pa = document.createElement('span'),
el = document.createElement('a'),
ch = document.createElement('img');

ch.setAttribute('src', chrome.extension.getURL('img/16.png'));
pa.classList.add('web-to-plex--container');

el.textContent = 'W2P+';
el.title = 'Loading...';
el.classList.add('web-to-plex-button');

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

return el;
}

function getIMDbID() {
let $link = document.querySelector(
'[href*="imdb.com/title/tt"]'
);
if ($link) {
let link = $link.href.replace(/^.*imdb\.com\/title\//, '');
return link.replace('/maindetails', '');
}
}

parseOptions().then(init);
2 changes: 1 addition & 1 deletion src/deps/flenix/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function isMoviePage() {
}

function isMoviePageReady() {
return !!document.querySelector('iframe[title="Disqus"]');
return !!document.querySelector('iframe[title*="Disqus"]');
}

function init() {
Expand Down
4 changes: 2 additions & 2 deletions src/deps/letterboxd/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ function renderPlexButton() {

function getIMDbID() {
let $link = document.querySelector(
'.track-event[href^="http://www.imdb.com/title/tt"]'
'.track-event[href*="imdb.com/title/tt"]'
);
if ($link) {
let link = $link.href.replace('http://www.imdb.com/title/', '');
let link = $link.href.replace(/^.*imdb\.com\/title\//, '');
return link.replace('/maindetails', '');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/deps/movieo/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ function renderPlexButton() {

function getIMDbID() {
let $link = document.querySelector(
'.tt-parent[href^="http://www.imdb.com/title/tt"]'
'.tt-parent[href*="imdb.com/title/tt"]'
);
if ($link)
return $link.href.replace('http://www.imdb.com/title/', '');
return $link.href.replace(/^.*imdb\.com\/title\//, '');
}
75 changes: 75 additions & 0 deletions src/deps/rottentomatoes/cs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.web-to-plex--container {
color: #fff!important;

display: block;
margin-top: 6px;
}

.web-to-plex-button {
background-color: #f45a26!important;
border: 1px solid #f45a26!important;
border-radius: 4px;
color: #fff!important;
font-size: 16px;
font-weight: bold;

display: inline-block;
line-height: 1.25;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
vertical-align: middle;
white-space: nowrap;

cursor: pointer;
}

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

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

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

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

#tt--0-0 {
background-color: #666!important;
border-color: #666!important;
}

#tt--0-0:hover {
background-color: #888!important;
border-color: #888!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;
}
95 changes: 95 additions & 0 deletions src/deps/rottentomatoes/cs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* global wait, modifyPlexButton, parseOptions, findPlexMedia */
function init() {
wait(
() => document.querySelector('#reviews'),
() => initPlexThingy(isMovie()? 'movie': 'show')
);
}

function isMovie() {
return /^\/m/.test(window.location.pathname);
}

function isShow() {
return /^\/t/.test(window.location.pathname);
}

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

let $title = document.querySelector('.playButton + .title, [itemprop="name"]'),
$year = (type == 'movie'? $title.nextElementSibling: $title.querySelector('.subtle'));

if (!$title || !$year)
return modifyPlexButton(
$button,
'error',
'Could not extract title or year from Rotten Tomatoes'
);

let title = $title.textContent.trim().replace(/(.+)\:[^]*$/, type == 'movie'? '$&': '$1'),
year = $year.textContent.replace(/\D+/g, '').trim(),
Db = await getIDs({ title, year, type }),
IMDbID = Db.imdb,
TMDbID = Db.tmdb,
TVDbID = Db.tvdb;

if($button.ch)
$button.ch.querySelector('em').innerText = `${ title } (${ year })`;

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

function renderPlexButton(type) {
let $actions = document.querySelector('.franchiseLink, #topSection > *');
if (!$actions)
return;

if(type == 'movie') {
let pa = document.createElement('a'),
ma = document.createElement('div'),
el = document.createElement('button'),
ch = document.createElement('div');

ch.setAttribute('style', 'line-height:34px');

el.classList.add('web-to-plex-button');
ma.classList.add('pull-right', 'hidden-xs');
pa.classList.add('white', 'web-to-plex--container');

ch.innerHTML =
`
<span class="hidden-xs-inline">
<strong>Web to Plex:</strong>
</span>
<em>Loading...</em>
`;
el.textContent = 'Web to Plex+';
el.title = 'Loading...';

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

return { el, ch };
} else {
let pa = document.createElement('div'),
el = document.createElement('a');

el.classList.add('fullWidth', 'web-to-plex-button');
pa.classList.add('poster_button', 'hidden-xs');

el.textContent = 'Web to Plex+';
el.title = 'Loading...';

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

return { el };
}
}

parseOptions().then(init);
Binary file added src/img/rottentomatoes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage_url": "https://github.com/Ephellon/web-to-plex/",

"manifest_version": 2,
"version": "1.2.0.1",
"version": "1.2.1.0",
// Firefox Support =>
// "applications": {
// "gecko": {
Expand Down Expand Up @@ -91,6 +91,14 @@
"matches": ["*://*.verizon.com/*"],
"js": ["utils.js", "deps/verizon/cs.js"],
"css": ["deps/verizon/cs.css"]
},{
"matches": ["*://*.couchpotato.life/*/*"],
"js": ["utils.js", "deps/couchpotato/cs.js"],
"css": ["deps/couchpotato/cs.css"]
},{
"matches": ["*://*.rottentomatoes.com/*/*"],
"js": ["utils.js", "deps/rottentomatoes/cs.js"],
"css": ["deps/rottentomatoes/cs.css"]
}
],

Expand Down

0 comments on commit afdeb40

Please sign in to comment.