From 35990a8d0ada693b410aa413cc0be8d3ff1ba83f Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 27 Jan 2023 19:21:25 -0800 Subject: [PATCH] Add archive --- README.md | 10 ++++++++++ archive/index.js | 8 ++++++++ archive/package.json | 19 +++++++++++++++++++ archive/wrangler.toml.example | 4 ++++ package.json | 3 ++- 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 archive/index.js create mode 100644 archive/package.json create mode 100644 archive/wrangler.toml.example diff --git a/README.md b/README.md index d127cbd..e66805d 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,16 @@ https://x.y.workers.dev?https://www.instagram.com/p/{POST_ID}/ > (Page with the Instagram post's embedded view in it) ``` +## archive + +Redirects a webpage to the corresponding [archive.ph](https://archive.ph) +capture. Useful to bypass news article paywalls. + +``` +https://x.y.workers.dev?https://example.com +> (HTTP redirect to https://archive.ph/https://example.com) +``` +

Command Line Utilities

## pwned diff --git a/archive/index.js b/archive/index.js new file mode 100644 index 0000000..fbcdc7d --- /dev/null +++ b/archive/index.js @@ -0,0 +1,8 @@ +export default { + async fetch(request) { + const url = new URL(request.url); + const queryString = decodeURIComponent(url.search.substring(1)); + + return Response.redirect(`https://archive.ph/${queryString}`); + } +} diff --git a/archive/package.json b/archive/package.json new file mode 100644 index 0000000..61f6278 --- /dev/null +++ b/archive/package.json @@ -0,0 +1,19 @@ +{ + "name": "archive", + "version": "0.2.0", + "description": "Web utility that automatically sends a webpage to archive.ph.", + "license": "ISC", + "author": "Ardis Lu", + "private": true, + "scripts": { + "dev": "wrangler dev", + "publish": "wrangler publish" + }, + "dependencies": { + "html-entities": "^2.3.3" + }, + "repository": { + "type": "git", + "url": "https://github.com/ardislu/cloudflare-workers.git" + } +} diff --git a/archive/wrangler.toml.example b/archive/wrangler.toml.example new file mode 100644 index 0000000..c1dbb8f --- /dev/null +++ b/archive/wrangler.toml.example @@ -0,0 +1,4 @@ +name = 'archive' +main = 'index.js' +compatibility_date = '2023-01-27' +route = { pattern = 'archive.example.com', custom_domain = true } diff --git a/package.json b/package.json index 5b43dc8..2444cd0 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "hash", "style", "unroll", - "buttcoin" + "buttcoin", + "archive" ] } -- 2.47.3