From 49418963c9da1838fa0a8f840a35232a60eb2924 Mon Sep 17 00:00:00 2001 From: Arcade Wise Date: Tue, 2 Jun 2026 14:08:07 -0400 Subject: [PATCH 1/2] Add support for althistory.com --- plugin/js/parsers/AlthistParser.js | 90 ++++++++++++++++++++++++++++++ plugin/popup.html | 1 + 2 files changed, 91 insertions(+) create mode 100644 plugin/js/parsers/AlthistParser.js diff --git a/plugin/js/parsers/AlthistParser.js b/plugin/js/parsers/AlthistParser.js new file mode 100644 index 000000000..581f9301a --- /dev/null +++ b/plugin/js/parsers/AlthistParser.js @@ -0,0 +1,90 @@ +"use strict"; + +parserFactory.register("althistory.com", () => new AlthistoryParser()); + +class AlthistoryParser extends Parser { + constructor() { + super(); + this.cache = new FetchCache(); + this.minimumThrottle = 50; //182 at 20 + this.expectedChapterUrl = null; + } + + async getChapterUrls(dom) { + let chapters = [...dom.querySelectorAll(".threadmark_depth0 > ul > li > a")]; + // .filter(this.isLinkToChapter); + return chapters.map(a => util.hyperLinkToChapter(a)); + } + + isLinkToChapter(link) { + return !link.querySelector("date") + && !(new URL(link.href).pathname.startsWith("/awards/award")); + } + + findContent(dom) { + return Parser.findConstrutedContent(dom); + } + + extractTitleImpl(dom) { + return dom.querySelector(".threadmarkLabel"); + } + + extractAuthor(dom) { + let authorLabel = dom.querySelector("a.username"); + return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent; + } + + async fetchChapter(url) { + let article = await this.fetchArticle(url); + if (!article && this.expectedChapterUrl && (this.expectedChapterUrl != url)) { + article = await this.fetchArticle(this.expectedChapterUrl); + } + if (article == null) { + throw new Error(`Can not find chapter ${url}`); + } + this.expectedChapterUrl = this.findExpectedNextChapter(article); + + let newDoc = Parser.makeEmptyDocForContent(url); + this.addTitleToChapter(newDoc, article); + let content = article.querySelector("article.message-body"); + util.resolveLazyLoadedImages(content, "img.lazyload"); + newDoc.content.appendChild(content); + return newDoc.dom; + } + + async fetchArticle(url) { + let fetchedDom = await this.cache.fetch(url); + let newUrl = new URL(url); + let id = newUrl.hash.substring(1); + let parent = fetchedDom.querySelector(`article.message[data-content='${id}']`); + if (parent === null) + { + parent = fetchedDom.querySelector("#" + id)?.parentElement; + } + return parent; + } + + findCoverImageUrl(dom) { + return util.getFirstImgSrc(dom, ".threadmarkListingHeader-icon"); + } + + findExpectedNextChapter(article) { + return article.querySelector("li.threadmark-nav") + ?.querySelector("a:nth-of-type(3)") + ?.href; + } + + addTitleToChapter(newDoc, parent) { + let titleElement = parent.querySelector("span.threadmarkLabel"); + if (titleElement !== null) + { + let title = newDoc.dom.createElement("h1"); + title.textContent = titleElement.textContent.trim(); + newDoc.content.appendChild(title); + } + } + + getInformationEpubItemChildNodes(dom) { + return [...dom.querySelectorAll("article.threadmarkListingHeader-extraInfoChild")]; + } +} diff --git a/plugin/popup.html b/plugin/popup.html index 06fcb6422..4e6971df0 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -621,6 +621,7 @@

Instructions

+ From 04a7ed148a7256c6f14f5c13f538aa64d5f7ebd2 Mon Sep 17 00:00:00 2001 From: Arcade Wise Date: Tue, 2 Jun 2026 14:13:44 -0400 Subject: [PATCH 2/2] asdf --- package.json | 3 ++- readme.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f8b754b65..efc6c7fb6 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,8 @@ { "name": "nothing0074", "email": "phong322010@proton.me" }, { "name": "Justin Mott", "email": "justinmmott@gmail.com" }, { "name": "mobedoor" }, - { "name": "nitramkh", "email": "nitramkh@gmail.com" } + { "name": "nitramkh", "email": "nitramkh@gmail.com" }, + { "name": "Arcade Wise", "email": "l3gacy.b3ta@gmail.com"} ], "license": "GPL-3.0-only", "bugs": { diff --git a/readme.md b/readme.md index d742fcdde..5dfb38a99 100644 --- a/readme.md +++ b/readme.md @@ -814,6 +814,7 @@ Don't forget to give the project a star! Thanks again!
  • Justin Mott
  • mobedoor
  • nitramkh
  • +
  • Arcade Wise (parser for althistory.com)