|
|
|
@ -9,7 +9,6 @@ import type {
|
|
|
|
|
HTMLDocument,
|
|
|
|
|
} from "https://denopkg.dev/gh/Ruthenic/deno-dom@master/src/dom/document.ts";
|
|
|
|
|
import { ID } from "../types.d.ts";
|
|
|
|
|
import asyncForEach from "../utils/asyncForeach.ts";
|
|
|
|
|
|
|
|
|
|
export default class Work {
|
|
|
|
|
#session: {
|
|
|
|
@ -76,13 +75,17 @@ export default class Work {
|
|
|
|
|
(t) => this.tags.push(t.children[0].innerText),
|
|
|
|
|
);
|
|
|
|
|
Array.from(
|
|
|
|
|
(this.#document.querySelector("dd.relationship > ul.commas") as Element)
|
|
|
|
|
(this.#document.querySelector(
|
|
|
|
|
"dd.relationship > ul.commas",
|
|
|
|
|
) as Element)
|
|
|
|
|
.children,
|
|
|
|
|
).map(
|
|
|
|
|
(t) => this.tags.push(t.children[0].innerText),
|
|
|
|
|
);
|
|
|
|
|
Array.from(
|
|
|
|
|
(this.#document.querySelector("dd.character > ul.commas") as Element)
|
|
|
|
|
(this.#document.querySelector(
|
|
|
|
|
"dd.character > ul.commas",
|
|
|
|
|
) as Element)
|
|
|
|
|
.children,
|
|
|
|
|
).map(
|
|
|
|
|
(t) => this.tags.push(t.children[0].innerText),
|
|
|
|
@ -107,7 +110,8 @@ export default class Work {
|
|
|
|
|
//CW: horrifying jank
|
|
|
|
|
async populateChapters() {
|
|
|
|
|
const firstChapterUrl =
|
|
|
|
|
(this.#document.querySelector("li.chapter > a") as Element).getAttribute(
|
|
|
|
|
(this.#document.querySelector("li.chapter > a") as Element)
|
|
|
|
|
.getAttribute(
|
|
|
|
|
"href",
|
|
|
|
|
) as string + "?view_adult=true";
|
|
|
|
|
const res = await this.#session.get(firstChapterUrl);
|
|
|
|
@ -116,8 +120,6 @@ export default class Work {
|
|
|
|
|
"text/html",
|
|
|
|
|
) as HTMLDocument;
|
|
|
|
|
|
|
|
|
|
const promises: Promise<void>[] = [];
|
|
|
|
|
|
|
|
|
|
Array.from((document.getElementById("selected_id") as Element).children)
|
|
|
|
|
.sort(
|
|
|
|
|
(a, b) => {
|
|
|
|
@ -125,20 +127,15 @@ export default class Work {
|
|
|
|
|
Number(b.getAttribute("value"));
|
|
|
|
|
},
|
|
|
|
|
).forEach((c) => {
|
|
|
|
|
promises.push((async (c: Element) => {
|
|
|
|
|
const newChapter = new Chapter(
|
|
|
|
|
this.id,
|
|
|
|
|
c.getAttribute("value") as string,
|
|
|
|
|
this.#session,
|
|
|
|
|
this.#DOMParser,
|
|
|
|
|
);
|
|
|
|
|
await 1; //shut up
|
|
|
|
|
this.chapters.push(
|
|
|
|
|
newChapter,
|
|
|
|
|
);
|
|
|
|
|
})(c));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await Promise.all(promises);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|