Skip to content

Commit

Permalink
Merge branch 'pr/136' into beta-branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephellon committed Dec 18, 2019
2 parents 8941894 + 397e077 commit 5f8816e
Show file tree
Hide file tree
Showing 14 changed files with 66 additions and 46 deletions.
Binary file modified moz.xpi
Binary file not shown.
Binary file modified moz.zip
Binary file not shown.
1 change: 0 additions & 1 deletion moz/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@
width: 180px !important;

transition: all 0.3s ease !important;
transition: opacity 1s ease !important;
}

.web-to-plex-button.hide {
Expand Down
5 changes: 4 additions & 1 deletion moz/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"homepage_url": "https://github.com/SpaceK33z/web-to-plex/",

"manifest_version": 2,
"version": "4.1.1.4",
"version": "4.1.1.6",
"browser_specific_settings": {
"gecko": {
"id": "[email protected]",
Expand All @@ -24,6 +24,7 @@
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",

"content_scripts": [
// Allow media downloads
{
"matches": [
"*://*.openload.co/*", "*://*.oload.co/*",
Expand Down Expand Up @@ -69,11 +70,13 @@
"all_frames": true
},

// Testing purposes only
{
"matches": ["*://ephellon.github.io/web.to.plex/test/*"],
"js": ["utils.js", "__test__.js"]
},

// The sites
{
"matches": ["*://*.movieo.me/*"],
"js": ["history-hack.js", "utils.js", "movieo$.js"]
Expand Down
12 changes: 8 additions & 4 deletions moz/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ class Prompt {
}
}

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

function addListener(element, eventName, callback = event => {}) {
eventName = eventName.replace(/^(on)?/, 'on');
callback = callback.toString().replace(/;+$/g, '');
Expand Down Expand Up @@ -1903,7 +1907,7 @@ for(let index = 0, length = builtin_array.length; builtinElement && index < leng
url = new URL(builtin[i]),
js = name.replace(/^builtin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

builtin_sites[r] = o;

Expand All @@ -1928,7 +1932,7 @@ for(let index = 0, length = builtin_array.length; builtinElement && index < leng
url = new URL(builtins[title]),
js = name.replace(/^builtin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

builtin_sites[r] = o;

Expand Down Expand Up @@ -2006,7 +2010,7 @@ for(let index = 0, length = plugin_array.length; pluginElement && index < length
url = new URL(plugin[i]),
js = name.replace(/^plugin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

plugin_sites[r] = o;

Expand All @@ -2031,7 +2035,7 @@ for(let index = 0, length = plugin_array.length; pluginElement && index < length
url = new URL(plugins[title]),
js = name.replace(/^plugin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

plugin_sites[r] = o;

Expand Down
8 changes: 6 additions & 2 deletions moz/plugn.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ function RandomName(length = 16, symbol = '') {
return values.join(symbol).replace(/^[^a-z]+/i, '');
};

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

async function prepare({ code, alias, type, allowed, url }) {

let DATE = (new Date),
Expand All @@ -250,7 +254,7 @@ async function prepare({ code, alias, type, allowed, url }) {
Type = type.replace(/^\w/, ($0, $$, $_) => $0.toUpperCase());

let org = url.origin,
ali = url.host.replace(/^(ww\w+\.|\w{2}\.)/i, '');
ali = TLDHost(url.host);

let { authorized, ...A } = await GetAuthorization(alias);

Expand Down Expand Up @@ -459,7 +463,7 @@ let tabchange = async tabs => {

url = new URL(url);
org = url.origin;
ali = url.host.replace(/^(ww\w+\.|\w{2}\.)/i, '');
ali = TLDHost(url.host);
type = (load(`builtin:${ ali }`) + '') == 'true'? 'script': 'plugin';
js = load(`${ type }:${ ali }`);
code = cache[ali];
Expand Down
28 changes: 17 additions & 11 deletions moz/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ let configuration, init, Update;
document.body.append(frame);
}

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

// Send an update query to background.js
Update = (type, options = {}, postToo) => {
if(configuration)
Expand Down Expand Up @@ -1044,7 +1048,7 @@ let configuration, init, Update;
};

if(configuration) {
let host = location.host.replace(/^(ww\w+\.)/, ''),
let host = TLDHost(location.host),
doms = configuration.__domains.split(',');

if(!~doms.indexOf(host))
Expand Down Expand Up @@ -1098,7 +1102,9 @@ let configuration, init, Update;
tid = TVDbID || null, // TVDbID
rqut = apit, // request type: tmdb, imdb, or tvdb
manable = __CONFIG__.ManagerSearch && !(rerun & 0b1000), // is the user's "Manager Searches" option enabled?
UTF_16 = /[^0\u0020-\u007e, 1\u00a1\u00bf-\u00ff, 2\u0100-\u017f, 3\u0180-\u024f, 4\u0300-\u036f, 5\u0370-\u03ff, 6\u0400-\u04ff, 7\u0500-\u052f, 8\u20a0-\u20bf]+/g;
UTF_16 = /[^0\u0020-\u007e, 1\u00a1\u00bf-\u00ff, 2\u0100-\u017f, 3\u0180-\u024f, 4\u0300-\u036f, 5\u0370-\u03ff, 6\u0400-\u04ff, 7\u0500-\u052f, 8\u20a0-\u20bf]+/g,
MV = /^(movies?|films?|cinemas?)$/i.test(apit),
TV = /^(tv[\s\-]*(?:shows?|series)?)$/i.test(apit);

type = type || null;
meta = { ...meta, mode: 'cors' };
Expand Down Expand Up @@ -1150,9 +1156,9 @@ let configuration, init, Update;
/* the rest of this function is a beautiful mess that will need to be dealt with later... but it works */
let url =
(manable && title && __CONFIG__.usingOmbi && __CONFIG__.ombiURLRoot)?
`${ __CONFIG__.ombiURLRoot }api/v1/Search/${ (rqut == 'imdb' || rqut == 'tmdb' || apit == 'movie')? 'movie': 'tv' }/${ plus(title, '%20') }/?apikey=${ api.ombi }`:
`${ __CONFIG__.ombiURLRoot }api/v1/Search/${ (/^[it]mdb$/i.test(rqut) || MV)? 'movie': 'tv' }/${ plus(title, '%20') }/?apikey=${ api.ombi }`:
(manable && (__CONFIG__.usingRadarr || __CONFIG__.usingSonarr || __CONFIG__.usingMedusa /*|| __CONFIG__.usingSickBeard*/))?
(__CONFIG__.usingRadarr && (rqut == 'imdb' || rqut == 'tmdb') && __CONFIG__.radarrURLRoot)?
(__CONFIG__.usingRadarr && /^[it]mdb$/i.test(rqut) && __CONFIG__.radarrURLRoot)?
(mid)?
`${ __CONFIG__.radarrURLRoot }api/movie/lookup/tmdb?tmdbId=${ mid }&apikey=${ __CONFIG__.radarrToken }`:
(iid)?
Expand All @@ -1168,22 +1174,22 @@ let configuration, init, Update;
`${ __CONFIG__.medusaURLRoot }api/v2/internal/searchIndexersForShowName?query=${ plus(title) }&indexerId=0&api_key=${ __CONFIG__.medusaToken }`:
/* TODO: find a way to get CORS to work on Sick Beard URLs (localhost) */
// (__CONFIG__.usingSickBeard)?
// (tid)?
// `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&tvdbid=${ tid }`:
// `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&name=${ encodeURIComponent(title) }`:
// (tid)?
// `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&tvdbid=${ tid }`:
// `${ __CONFIG__.sickBeardURLRoot }api/${ __CONFIG__.sickBeardToken }/?cmd=sb.searchtvdb&name=${ encodeURIComponent(title) }`:
null:
(rqut == 'imdb' || (rqut == '*' && !iid && title) || (rqut == 'tvdb' && !iid && title && !(rerun & 0b1000)) && (rerun |= 0b1000))?
(iid)?
`https://www.omdbapi.com/?i=${ iid }&apikey=${ api.omdb }`:
(year)?
`https://www.omdbapi.com/?t=${ plus(title) }&y=${ year }&apikey=${ api.omdb }`:
`https://www.omdbapi.com/?t=${ plus(title) }&apikey=${ api.omdb }`:
(rqut == 'tmdb' || (rqut == '*' && !mid && title && year) || apit == 'movie')?
(rqut == 'tmdb' || (rqut == '*' && !mid && title && year) || MV)?
(apit && apid)?
`https://api.themoviedb.org/3/${ apit }/${ apid }?api_key=${ api.tmdb }`:
`https://api.themoviedb.org/3/${ MV? 'movie': 'tv' }/${ apid }?api_key=${ api.tmdb }`:
(iid || mid || tid)?
`https://api.themoviedb.org/3/find/${ iid || mid || tid }?api_key=${ api.tmdb }&external_source=${ iid? 'imdb': mid? 'tmdb': 'tvdb' }_id`:
`https://api.themoviedb.org/3/search/${ apit }?api_key=${ api.tmdb }&query=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
`https://api.themoviedb.org/3/search/${ MV? 'movie': 'tv' }?api_key=${ api.tmdb }&query=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
(rqut == 'tvdb' || (rqut == '*' && !tid && title) || (apid == tid))?
(tid)?
`https://api.tvmaze.com/shows/?thetvdb=${ tid }`:
Expand All @@ -1192,7 +1198,7 @@ let configuration, init, Update;
`https://api.tvmaze.com/search/shows?q=${ encodeURI(title) }`:
(title)?
(apit && year)?
`https://www.theimdbapi.org/api/find/${ apit }?title=${ encodeURI(title) }&year=${ year }`:
`https://www.theimdbapi.org/api/find/${ MV? 'movie': 'show' }?title=${ encodeURI(title) }&year=${ year }`:
`https://www.theimdbapi.org/api/find/movie?title=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
null;

Expand Down
Binary file modified src.crx
Binary file not shown.
Binary file modified src.zip
Binary file not shown.
11 changes: 1 addition & 10 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
"homepage_url": "https://github.com/SpaceK33z/web-to-plex/",

"manifest_version": 2,
"version": "4.1.1.4",
// Firefox Support =>
// "applications": {
// "gecko": {
// "id": "{05243336-ce19-46df-95af-680070c96134}",
// "strict_min_version": "57.0"
// "update_url": "https://ephellon.github.com/web.to.plex/update.json"
// }
// },
"version": "4.1.1.6",

"icons": {
"16": "img/16.png",
Expand Down Expand Up @@ -214,7 +206,6 @@
"persistent": true
},

// Disable/Comment "options_page" to enable FF support
"options_page": "options/index.html",
"options_ui": {
"page": "options/index.html",
Expand Down
12 changes: 8 additions & 4 deletions src/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ class Prompt {
}
}

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

function addListener(element, eventName, callback = event => {}) {
eventName = eventName.replace(/^(on)?/, 'on');
callback = callback.toString().replace(/;+$/g, '');
Expand Down Expand Up @@ -1925,7 +1929,7 @@ for(let index = 0, length = builtin_array.length; builtinElement && index < leng
url = new URL(builtin[i]),
js = name.replace(/^builtin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

builtin_sites[r] = o;

Expand All @@ -1950,7 +1954,7 @@ for(let index = 0, length = builtin_array.length; builtinElement && index < leng
url = new URL(builtins[title]),
js = name.replace(/^builtin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

builtin_sites[r] = o;

Expand Down Expand Up @@ -2028,7 +2032,7 @@ for(let index = 0, length = plugin_array.length; pluginElement && index < length
url = new URL(plugin[i]),
js = name.replace(/^plugin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

plugin_sites[r] = o;

Expand All @@ -2053,7 +2057,7 @@ for(let index = 0, length = plugin_array.length; pluginElement && index < length
url = new URL(plugins[title]),
js = name.replace(/^plugin_/i, ''),
o = url.origin,
r = url.host.replace(/^(ww\w+\.)/, '');
r = TLDHost(url.host);

plugin_sites[r] = o;

Expand Down
8 changes: 6 additions & 2 deletions src/plugn.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ function RandomName(length = 16, symbol = '') {
return values.join(symbol).replace(/^[^a-z]+/i, '');
};

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

async function prepare({ code, alias, type, allowed, url }) {

let DATE = (new Date),
Expand All @@ -250,7 +254,7 @@ async function prepare({ code, alias, type, allowed, url }) {
Type = type.replace(/^\w/, ($0, $$, $_) => $0.toUpperCase());

let org = url.origin,
ali = url.host.replace(/^(ww\w+\.|\w{2}\.)/i, '');
ali = TLDHost(url.host);

let { authorized, ...A } = await GetAuthorization(alias);

Expand Down Expand Up @@ -450,7 +454,7 @@ let tabchange = async tabs => {

url = new URL(url);
org = url.origin;
ali = url.host.replace(/^(ww\w+\.|\w{2}\.)/i, '');
ali = TLDHost(url.host);
type = (load(`builtin:${ ali }`) + '') == 'true'? 'script': 'plugin';
js = load(`${ type }:${ ali }`);
code = cache[ali];
Expand Down
1 change: 0 additions & 1 deletion src/sites/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@
width: 180px !important;

transition: all 0.3s ease !important;
transition: opacity 1s ease !important;
}

.web-to-plex-button.hide {
Expand Down
26 changes: 16 additions & 10 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,10 @@ let configuration, init, Update;
document.body.append(frame);
}

function TLDHost(host) {
return host.replace(/^(ww\w+|\w{2})\./, '');
}

// Send an update query to background.js
Update = (type, options = {}, postToo) => {
if(configuration)
Expand Down Expand Up @@ -842,8 +846,8 @@ let configuration, init, Update;
}

// self explanatory, returns an object; sets the configuration variable
function ParsedOptions() {
return options()
async function ParsedOptions() {
return await options()
.then(
options => {
configuration = {};
Expand Down Expand Up @@ -1042,7 +1046,7 @@ let configuration, init, Update;
};

if(configuration) {
let host = location.host.replace(/^(ww\w+\.)/, ''),
let host = TLDHost(location.host),
doms = configuration.__domains.split(',');

if(!~doms.indexOf(host))
Expand Down Expand Up @@ -1096,7 +1100,9 @@ let configuration, init, Update;
tid = TVDbID || null, // TVDbID
rqut = apit, // request type: tmdb, imdb, or tvdb
manable = __CONFIG__.ManagerSearch && !(rerun & 0b1000), // is the user's "Manager Searches" option enabled?
UTF_16 = /[^0\u0020-\u007e, 1\u00a1\u00bf-\u00ff, 2\u0100-\u017f, 3\u0180-\u024f, 4\u0300-\u036f, 5\u0370-\u03ff, 6\u0400-\u04ff, 7\u0500-\u052f, 8\u20a0-\u20bf]+/g;
UTF_16 = /[^0\u0020-\u007e, 1\u00a1\u00bf-\u00ff, 2\u0100-\u017f, 3\u0180-\u024f, 4\u0300-\u036f, 5\u0370-\u03ff, 6\u0400-\u04ff, 7\u0500-\u052f, 8\u20a0-\u20bf]+/g,
MV = /^(movies?|films?|cinemas?)$/i.test(apit),
TV = /^(tv[\s\-]*(?:shows?|series)?)$/i.test(apit);

type = type || null;
meta = { ...meta, mode: 'cors' };
Expand Down Expand Up @@ -1148,9 +1154,9 @@ let configuration, init, Update;
/* the rest of this function is a beautiful mess that will need to be dealt with later... but it works */
let url =
(manable && title && __CONFIG__.usingOmbi && __CONFIG__.ombiURLRoot)?
`${ __CONFIG__.ombiURLRoot }api/v1/Search/${ (rqut == 'imdb' || rqut == 'tmdb' || apit == 'movie')? 'movie': 'tv' }/${ plus(title, '%20') }/?apikey=${ api.ombi }`:
`${ __CONFIG__.ombiURLRoot }api/v1/Search/${ (/^[it]mdb$/i.test(rqut) || MV)? 'movie': 'tv' }/${ plus(title, '%20') }/?apikey=${ api.ombi }`:
(manable && (__CONFIG__.usingRadarr || __CONFIG__.usingSonarr || __CONFIG__.usingMedusa /*|| __CONFIG__.usingSickBeard*/))?
(__CONFIG__.usingRadarr && (rqut == 'imdb' || rqut == 'tmdb') && __CONFIG__.radarrURLRoot)?
(__CONFIG__.usingRadarr && /^[it]mdb$/i.test(rqut) && __CONFIG__.radarrURLRoot)?
(mid)?
`${ __CONFIG__.radarrURLRoot }api/movie/lookup/tmdb?tmdbId=${ mid }&apikey=${ __CONFIG__.radarrToken }`:
(iid)?
Expand All @@ -1176,12 +1182,12 @@ let configuration, init, Update;
(year)?
`https://www.omdbapi.com/?t=${ plus(title) }&y=${ year }&apikey=${ api.omdb }`:
`https://www.omdbapi.com/?t=${ plus(title) }&apikey=${ api.omdb }`:
(rqut == 'tmdb' || (rqut == '*' && !mid && title && year) || apit == 'movie')?
(rqut == 'tmdb' || (rqut == '*' && !mid && title && year) || MV)?
(apit && apid)?
`https://api.themoviedb.org/3/${ apit }/${ apid }?api_key=${ api.tmdb }`:
`https://api.themoviedb.org/3/${ MV? 'movie': 'tv' }/${ apid }?api_key=${ api.tmdb }`:
(iid || mid || tid)?
`https://api.themoviedb.org/3/find/${ iid || mid || tid }?api_key=${ api.tmdb }&external_source=${ iid? 'imdb': mid? 'tmdb': 'tvdb' }_id`:
`https://api.themoviedb.org/3/search/${ apit }?api_key=${ api.tmdb }&query=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
`https://api.themoviedb.org/3/search/${ MV? 'movie': 'tv' }?api_key=${ api.tmdb }&query=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
(rqut == 'tvdb' || (rqut == '*' && !tid && title) || (apid == tid))?
(tid)?
`https://api.tvmaze.com/shows/?thetvdb=${ tid }`:
Expand All @@ -1190,7 +1196,7 @@ let configuration, init, Update;
`https://api.tvmaze.com/search/shows?q=${ encodeURI(title) }`:
(title)?
(apit && year)?
`https://www.theimdbapi.org/api/find/${ apit }?title=${ encodeURI(title) }&year=${ year }`:
`https://www.theimdbapi.org/api/find/${ MV? 'movie': 'show' }?title=${ encodeURI(title) }&year=${ year }`:
`https://www.theimdbapi.org/api/find/movie?title=${ encodeURI(title) }${ year? '&year=' + year: '' }`:
null;

Expand Down

0 comments on commit 5f8816e

Please sign in to comment.