From 7b3bcf94c40d9f7c98e37b96d36e51b64f478729 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 19 Jul 2026 04:09:13 +0000 Subject: [PATCH] Race a direct CORS fetch alongside Jina in cliche highlighter URL loading Fire both requests in parallel when loading a URL. Prefer the Jina Reader result; if Jina fails (HTTP error or network), quietly fall back to the direct fetch in case the site serves open CORS headers. If both fail, show the original Jina error. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_014q3Z2gAqr6XZxMkQBTaoem --- llm-cliche-highlighter.html | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/llm-cliche-highlighter.html b/llm-cliche-highlighter.html index 770b72ac..0cf17f6d 100644 --- a/llm-cliche-highlighter.html +++ b/llm-cliche-highlighter.html @@ -688,6 +688,8 @@

Matches

// URL loading: the page URL's #fragment holds the article URL, and the text is // fetched through the Jina Reader proxy (https://r.jina.ai/) as plain text. +// A direct fetch of the URL races alongside as a quiet fallback in case the +// site serves open CORS headers and Jina fails. function normalizeUrl(raw) { const url = raw.trim(); @@ -795,12 +797,27 @@

Matches

history.replaceState(null, '', fragmentFromUrl(url)); loadUrlBtn.disabled = true; setUrlStatus('Fetching ' + url + ' via r.jina.ai …'); - try { - const response = await fetch('https://r.jina.ai/' + url, { - headers: { 'X-Return-Format': 'text' } - }); + const fetchText = async (target, options) => { + const response = await fetch(target, options); if (!response.ok) throw new Error('HTTP ' + response.status); - const text = await response.text(); + return response.text(); + }; + const jinaPromise = fetchText('https://r.jina.ai/' + url, { + headers: { 'X-Return-Format': 'text' } + }); + const directPromise = fetchText(url); + directPromise.catch(() => {}); + try { + let text; + try { + text = await jinaPromise; + } catch (jinaErr) { + try { + text = await directPromise; + } catch (directErr) { + throw jinaErr; + } + } input.value = text; run(); setUrlStatus('Loaded ' + text.length.toLocaleString() + ' characters from ' + url);