]> git.ardis.lu - cloudflare-workers/commitdiff
Add archive
authorArdis Lu <ardisglu@gmail.com>
Sat, 28 Jan 2023 03:21:25 +0000 (19:21 -0800)
committerArdis Lu <ardisglu@gmail.com>
Sat, 28 Jan 2023 03:21:25 +0000 (19:21 -0800)
README.md
archive/index.js [new file with mode: 0644]
archive/package.json [new file with mode: 0644]
archive/wrangler.toml.example [new file with mode: 0644]
package.json

index d127cbd311773a94ee88a8f647780cefb0dc65bd..e66805d9c236803c7bcb75f25af59ee47f00705d 100644 (file)
--- 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)
+```
+
 <h1 align="center">Command Line Utilities</h1>
 
 ## pwned
diff --git a/archive/index.js b/archive/index.js
new file mode 100644 (file)
index 0000000..fbcdc7d
--- /dev/null
@@ -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 (file)
index 0000000..61f6278
--- /dev/null
@@ -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 (file)
index 0000000..c1dbb8f
--- /dev/null
@@ -0,0 +1,4 @@
+name = 'archive'
+main = 'index.js'
+compatibility_date = '2023-01-27'
+route = { pattern = 'archive.example.com', custom_domain = true }
index 5b43dc887a1a92c9bf4c20eb35a57d8708bb279f..2444cd078cebdc32b82d4ad0aedb72c56f83cd7a 100644 (file)
@@ -27,6 +27,7 @@
     "hash",
     "style",
     "unroll",
-    "buttcoin"
+    "buttcoin",
+    "archive"
   ]
 }
This page took 0.042951 seconds and 4 git commands to generate.