Skip to content

Add support for Althistory.com#2703

Open
l3gacyb3ta wants to merge 3 commits into
dteviot:ExperimentalTabModefrom
l3gacyb3ta:ExperimentalTabMode
Open

Add support for Althistory.com#2703
l3gacyb3ta wants to merge 3 commits into
dteviot:ExperimentalTabModefrom
l3gacyb3ta:ExperimentalTabMode

Conversation

@l3gacyb3ta
Copy link
Copy Markdown

No description provided.

@dteviot
Copy link
Copy Markdown
Owner

dteviot commented Jun 3, 2026

@l3gacyb3ta

You've basically copy/pasted the SpaceBattles parser.
Recommended way would be to derive from SpaceBattles. e.g.

Add this to top of the Spacebattles.js

parserFactory.register("althistory.com", () => new AlthistoryParser());

And add this to bottom

class AlthistoryParser extends SpacebattlesParser {
    constructor() {
        super();
    }

    async getChapterUrls(dom) {
        let chapters = [...dom.querySelectorAll(".threadmark_depth0 > ul > li > a")];
        return chapters.map(a => util.hyperLinkToChapter(a));
    }

    extractTitleImpl(dom) {
        return dom.querySelector(".threadmarkLabel");
    }

    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;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants