Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions llm-cliche-highlighter.html
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ <h2>Matches</h2>

// 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();
Expand Down Expand Up @@ -795,12 +797,27 @@ <h2>Matches</h2>
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);
Expand Down
Loading