Skip to content

fix(Comix): restore chapter fetch blocked by Cloudflare in WebView#213

Closed
acepilot147 wants to merge 1 commit into
inkdex:0.9/stablefrom
acepilot147:bugfix/comix-cloudflare-webview-ua
Closed

fix(Comix): restore chapter fetch blocked by Cloudflare in WebView#213
acepilot147 wants to merge 1 commit into
inkdex:0.9/stablefrom
acepilot147:bugfix/comix-cloudflare-webview-ua

Conversation

@acepilot147

Copy link
Copy Markdown
Contributor

Summary

Restores Comix chapter fetching, which was broken by Cloudflare. The WebView (executeInWebView) runs under a macOS-Safari User-Agent while cf_clearance is issued for the iPad app UA, so the WebView's own bundle/API requests were rejected and the chapter list never loaded; since executeInWebView has no UA option, the extension now reads the WebView's UA once and reuses it for native requests and the Cloudflare challenge. Also fixes the page-size rewrite, where the "$1100" replacement string was mis-parsed into an out-of-range page=1100 and returned zero chapters.

Checklist

Making changes

For updates to existing extensions

  • Bumped the version value in pbconfig.ts for each modified extension.

For new extensions

  • Generated tests with npx paperback-cli test --generate EXTENSION_NAME.

Testing changes

  • npm run conformance passes.
  • npm test -- EXTENSION_NAME passes.
  • Bundled the extension and verified it works in the Paperback app.

Committing changes

  • Commit messages follow the existing convention (type(Scope): summary, e.g. fix(EXTENSION_NAME): ...).

AI assistance

Pick one:

  • This PR contains no AI-assisted changes.
  • This PR is AI-assisted. I manually reviewed every change and added an Assisted-by: AGENT_NAME:MODEL_VERSION trailer to each AI-assisted commit.

- executeInWebView runs under a macOS-Safari User-Agent, but cf_clearance is issued for the iPad app UA, so the WebView's own resource loads (main.js) and the SPA's API requests were rejected by Cloudflare and the chapter list never loaded. executeInWebView exposes no User-Agent option, so read the WebView's UA once and reuse it for both native requests (interceptRequest) and the Cloudflare challenge (CloudflareError), binding cf_clearance to the identity the WebView actually uses.
- Fix the chapter page-size rewrite: the "$1100" replacement string is mis-parsed (the $1 backreference swallows the following digits), turning page=1&limit=20 into page=1100 (an out-of-range page) and returning zero chapters. Use a function replacement instead.

Assisted-by: Claude Code:claude-opus-4-8
@niclimcy niclimcy closed this Jun 12, 2026
acepilot147 added a commit to acepilot147/general-extensions that referenced this pull request Jun 12, 2026
…lpha.91)

Replace the WebView User-Agent workaround (rejected in inkdex#213) with the first-class alpha.91 APIs: set source.userAgent so the WebView runs under the app's default UA that cf_clearance is bound to, and adopt cloudflareBypassCompleted in place of the deprecated saveCloudflareBypassCookies. Bump @paperback/toolchain and @paperback/types to 1.0.0-alpha.91.

Also fix the chapter page-size rewrite: the "$1100" replacement string is mis-parsed (the $1 backreference swallows the trailing digits), turning limit=20 into page=1100 and returning zero chapters; use a function replacement.

Assisted-by: Claude Code:claude-opus-4-8
acepilot147 added a commit to acepilot147/general-extensions that referenced this pull request Jun 12, 2026
…lpha.91)

Replace the WebView User-Agent workaround (rejected in inkdex#213) with the first-class alpha.91 APIs: set source.userAgent so the WebView runs under the app's default UA that cf_clearance is bound to, and adopt cloudflareBypassCompleted in place of the deprecated saveCloudflareBypassCookies. Bump @paperback/toolchain and @paperback/types to 1.0.0-alpha.91.

Also fix the chapter page-size rewrite: the "$1100" replacement string is mis-parsed (the $1 backreference swallows the trailing digits), turning limit=20 into page=1100 and returning zero chapters; use a function replacement.

Assisted-by: Claude Code:claude-opus-4-8
niclimcy pushed a commit that referenced this pull request Jun 13, 2026
…lpha.91)

Replace the WebView User-Agent workaround (rejected in #213) with the first-class alpha.91 APIs: set source.userAgent so the WebView runs under the app's default UA that cf_clearance is bound to, and adopt cloudflareBypassCompleted in place of the deprecated saveCloudflareBypassCookies. Bump @paperback/toolchain and @paperback/types to 1.0.0-alpha.91.

Also fix the chapter page-size rewrite: the "$1100" replacement string is mis-parsed (the $1 backreference swallows the trailing digits), turning limit=20 into page=1100 and returning zero chapters; use a function replacement.

Assisted-by: Claude Code:claude-opus-4-8
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