1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import { Readability } from "npm:@mozilla/readability";
import jsdom from "npm:jsdom";
export default async function(req: Request): Promise<Response> {
const JSDOM = jsdom.JSDOM;
const url = new URL(req.url);
let resp = await fetch(url.pathname.substring(1));
// strip / from start of string
let body = await resp.text();
let doc = new JSDOM(body);
let reader = new Readability(doc.window.document);
let article = reader.parse();
return new Response(article.content, { headers: { "Content-Type": "text/html" } });
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
maxm-peachmagpie.web.val.run
v7
March 1, 2024