Contributing to WebPullBook

WebPullBook was created and is maintained by Wilton Gabriel, and is open to contributions from the open-source community under the GNU AGPLv3 (AGPL-3.0-or-later; releases up to v1.6.1-beta remain historically under the MIT License). The project uses native ES modules with no build step and no runtime dependencies, so you can load the repository folder directly in your browser and run unit checks with standard Node.js.

Ways to Contribute — Focus on Parser Development

Developing, improving, and adding parsers is the highest-impact way to expand WebPullBook across new platforms, CMS themes, and serialized fiction websites.

1. Develop & Add Parser Adapters (src/parsers/)

When a platform or CMS theme uses paginated JSON APIs, AJAX chapter lists, or non-standard DOM structures, implement a new subclass of BaseParser under src/parsers/, register it in src/parsers/index.js, and include anonymized HTML snapshot fixtures.

2. Improve the Generic Heuristic Parser

Following the General Compatibility First principle, improving BaseParser, GenericHtmlParser, or HtmlSanitizer allows entire families of websites and mirror domains to work automatically without domain-specific rules.

3. Request or Map New Site Layouts

Even if you do not write JavaScript, you can help parser development by inspecting a site's HTML (or using the Pick selector tool) and opening a New Site Layout / Adapter Support issue with the chapter list, chapter body, and volume CSS selectors.

4. Test Websites & Update Compatibility

Test WebPullBook on web novel platforms, blogs, or documentation sites and open a Pull Request updating docs/COMPATIBILITY.md (which automatically synchronizes the tables on this website).

5. Report Extraction Bugs with Logs

If an extraction or EPUB export fails on a specific chapter or index structure, open the Logs tab in WebPullBook, click Download Log, and attach the log to a GitHub Issue.

6. Cross-Browser & E-Reader Validation

Validate generated EPUB 2 and EPUB 3 files on Kindle, Kobo, PocketBook, Tolino, and mobile reading apps, or test the extension on Firefox 128+, Edge, and Brave.

How to Build and Add a New Parser Adapter

All parser adapters inherit from BaseParser (src/core/base-parser.js) and use structural DOM scoring (matchScore) so they remain resilient even when a website changes domains.

Minimal 4-step structure for adding a new parser adapter in src/parsers/:
// 1. Create src/parsers/my-layout-adapter.js extending BaseParser
import { BaseParser } from '../core/parser-engine.js';

export class MyLayoutParser extends BaseParser {
  constructor() {
    super({ id: 'my-layout', name: 'My Layout / CMS Adapter' });
  }

  // Score structural DOM signals (0 = no match, 70-95 = strong structural match)
  matchScore(doc, _url) {
    return doc.querySelector('.custom-chapter-index, #novel-toc-list') ? 85 : 0;
  }

  extractSiteMetadata(doc, _targetUrl) {
    return {
      title: doc.querySelector('h1.novel-title')?.textContent?.trim(),
      author: doc.querySelector('.novel-author a')?.textContent?.trim()
    };
  }

  collectChapterNodes(doc, targetUrl) {
    return Array.from(doc.querySelectorAll('#novel-toc-list a')).map((a) => ({
      url: new URL(a.getAttribute('href'), targetUrl).toString(),
      displayTitle: a.textContent.trim(),
      volume: 'Volume 01',
      included: true
    }));
  }

  findChapterContentRoot(doc) {
    return doc.querySelector('article.chapter-reader-body');
  }
}

// 2. Register an instance in src/parsers/index.js before genericHtmlParser
// 3. Add anonymized HTML fixtures in tests/fixtures/ and expectations in snapshots.json
// 4. Run `npm run check` and document the adapter in docs/COMPATIBILITY.md

Local Development & Testing

Linting and unit/snapshot tests run on the Node.js 22+ standard library without requiring npm install. Only the Chromium browser E2E test uses Playwright.

Verification commands:
# 1. Static lint, JS syntax, MV3 CSP, Markdown links, i18n parity, and website checks
npm run lint

# 2. Unit, sanitizer, ZIP, cache, exporter, and parser fixture snapshot tests
npm test

# 3. Run both lint and unit tests together
npm run check

# 4. Validate generated EPUB 2 & EPUB 3 files with W3C EPUBCheck (requires Java 21+ & EPUBCheck)
REQUIRE_EPUBCHECK=1 npm run test:epubcheck

# 5. End-to-End Chromium extension test (requires Playwright Chromium)
npm install
npx playwright install chromium
npm run test:e2e

Developer Documentation (CONTRIBUTING.md)

See the contributor guide in the repository for instructions on creating a BaseParser subclass, adding anonymized HTML fixtures under tests/fixtures/, and running the pre-PR checklist.

AI Coding Agent Instructions (AGENTS.md)

The repository includes an AGENTS.md file for AI coding tools (Codex, Cursor, Claude Code, Antigravity, Copilot), documenting module responsibilities, SRP boundaries, MV3 CSP rules, and verification steps.