From 560eb530bc03012f35102bc13933b32056749227 Mon Sep 17 00:00:00 2001 From: Morea Date: Sun, 4 Feb 2024 13:33:41 +0100 Subject: [PATCH] Support BHD library pages --- .../config/userscript.config.ts | 2 +- .../dist/find.unique.titles.user.js | 14 +++++------ Find Unique Titles/src/trackers/BHD.ts | 25 ++++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Find Unique Titles/config/userscript.config.ts b/Find Unique Titles/config/userscript.config.ts index d02c37d..7ee5d16 100644 --- a/Find Unique Titles/config/userscript.config.ts +++ b/Find Unique Titles/config/userscript.config.ts @@ -33,7 +33,7 @@ export const UserScriptConfig: IWebpackUserScript = { "https://hdbits.org/browse.php*", "https://passthepopcorn.me/torrents.php*", "https://passthepopcorn.me/torrents.php?type=seeding", - "https://beyond-hd.me/library/movies*", + "https://beyond-hd.me/library/*", "https://beyond-hd.me/torrents*", "https://cinemaz.to/movies*", "https://avistaz.to/movies*", diff --git a/Find Unique Titles/dist/find.unique.titles.user.js b/Find Unique Titles/dist/find.unique.titles.user.js index 88a785d..aa4e30d 100644 --- a/Find Unique Titles/dist/find.unique.titles.user.js +++ b/Find Unique Titles/dist/find.unique.titles.user.js @@ -8,7 +8,7 @@ // @match https://hdbits.org/browse.php* // @match https://passthepopcorn.me/torrents.php* // @match https://passthepopcorn.me/torrents.php?type=seeding -// @match https://beyond-hd.me/library/movies* +// @match https://beyond-hd.me/library/* // @match https://beyond-hd.me/torrents* // @match https://cinemaz.to/movies* // @match https://avistaz.to/movies* @@ -22,7 +22,7 @@ // @match https://filelist.io/browse.php* // @match https://jptv.club/torrents* // @match https://hd-torrents.org/torrents.php* -// @match https://iptorrents.com/t?* +// @match https://iptorrents.com/t* // @match https://kp.m-team.cc/* // @match https://ncore.pro/torrents.php* // @match https://greatposterwall.com/torrents.php* @@ -35,7 +35,7 @@ // @match https://torrentseeds.org/categories/* // @match https://www.morethantv.me/torrents/browse* // @match https://jpopsuki.eu/torrents.php* -// @match https://tntracker.org/*/?perPage=* +// @match https://tntracker.org/* // @grant GM.xmlHttpRequest // @grant GM.setValue // @grant GM.getValue @@ -391,7 +391,7 @@ }; const parseTorrentsFromTorrentsPage = () => { const requests = []; - document.querySelectorAll('tr[id^="torrentposter"]').forEach((element => { + Array.from(document.querySelectorAll('tr[id^="torrentposter"]')).forEach((element => { let imdbId = null; let libraryId = element.getAttribute("library"); if (libraryId) { @@ -419,7 +419,7 @@ })); return requests; }; - const parseTorrentsFromMoviesPage = () => { + const parseTorrentsFromLibraryPage = () => { const requests = []; document.querySelectorAll(".bhd-meta-box").forEach((element => { let imdbId = (0, _utils_utils__WEBPACK_IMPORTED_MODULE_0__.parseImdbIdFromLink)(element); @@ -433,7 +433,7 @@ })); return requests; }; - const isMoviesPage = () => window.location.href.includes("/movies"); + const isLibraryPage = () => window.location.href.includes("/library"); const isTorrentsPage = () => window.location.href.includes("/torrents"); class BHD { canBeUsedAsSource() { @@ -447,7 +447,7 @@ } async* getSearchRequest() { let requests = []; - if (isMoviesPage()) requests = parseTorrentsFromMoviesPage(); else if (isTorrentsPage()) requests = parseTorrentsFromTorrentsPage(); + if (isLibraryPage()) requests = parseTorrentsFromLibraryPage(); else if (isTorrentsPage()) requests = parseTorrentsFromTorrentsPage(); yield* (0, _tracker__WEBPACK_IMPORTED_MODULE_1__.toGenerator)(requests); } name() { diff --git a/Find Unique Titles/src/trackers/BHD.ts b/Find Unique Titles/src/trackers/BHD.ts index f45938f..f0113f5 100644 --- a/Find Unique Titles/src/trackers/BHD.ts +++ b/Find Unique Titles/src/trackers/BHD.ts @@ -1,7 +1,8 @@ import { parseImdbIdFromLink, parseResolution, - parseSize, parseTags + parseSize, + parseTags, } from "../utils/utils"; import { Category, @@ -44,10 +45,9 @@ const parseCategory = (element: Element) => { }; const parseTorrentsFromTorrentsPage = (): Array => { - const requests = []; - document - .querySelectorAll('tr[id^="torrentposter"]') - .forEach((element: HTMLElement) => { + const requests: Array> = []; + Array.from(document.querySelectorAll('tr[id^="torrentposter"]')).forEach( + (element) => { let imdbId = null; let libraryId = element.getAttribute("library"); if (libraryId) { @@ -58,7 +58,7 @@ const parseTorrentsFromTorrentsPage = (): Array => { } const tags = []; const torrentName = - element.children[1].querySelector('a[id^="torrent"]').textContent; + element.children[1].querySelector('a[id^="torrent"]')!!.textContent!!; if (torrentName.toUpperCase().includes("REMUX")) { tags.push("Remux"); } @@ -78,11 +78,12 @@ const parseTorrentsFromTorrentsPage = (): Array => { category: parseCategory(element), }; requests.push(request); - }); + } + ); return requests; }; -const parseTorrentsFromMoviesPage = (): Array => { +const parseTorrentsFromLibraryPage = (): Array => { const requests: Array = []; document.querySelectorAll(".bhd-meta-box").forEach((element) => { let imdbId = parseImdbIdFromLink(element as HTMLElement); @@ -98,8 +99,8 @@ const parseTorrentsFromMoviesPage = (): Array => { return requests; }; -const isMoviesPage = () => { - return window.location.href.includes("/movies"); +const isLibraryPage = () => { + return window.location.href.includes("/library"); }; const isTorrentsPage = () => { return window.location.href.includes("/torrents"); @@ -120,8 +121,8 @@ export default class BHD implements tracker { async *getSearchRequest(): AsyncGenerator { let requests: Array = []; - if (isMoviesPage()) { - requests = parseTorrentsFromMoviesPage(); + if (isLibraryPage()) { + requests = parseTorrentsFromLibraryPage(); } else if (isTorrentsPage()) { requests = parseTorrentsFromTorrentsPage(); }