neverstew-readable.web.val.run
Readme

Readable

Make any website instantly readable!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Readability } from "npm:@mozilla/readability"; // @ts-ignore
import { JSDOM } from "npm:jsdom";
export default async function(req: Request) {
let resp = await fetch(`https://${new URL(req.url).pathname}`, req);
let body = await resp.text();
let doc = new JSDOM(body);
let reader = new Readability(doc.window.document.cloneNode(true));
let article = reader.parse();
console.log(article.content);
return new Response(
`
<html>
<head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
/>
</head>
<body>
<main>
${article.content}
</main>
</body>
</html>
`,
{
headers: {
"Content-Type": "text/html",
},
},
);
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
March 2, 2024