-
+
@@ -237,7 +238,6 @@ export default function LinkDetails({ link, isOwnerOrMod }: Props) {
-
+
-
+
@@ -271,7 +271,6 @@ export default function LinkDetails({ link, isOwnerOrMod }: Props) {
+
+
+
+
+
+
+
+
Wayback Machine
+
+
+
+
+
+
);
diff --git a/lib/api/archive.ts b/lib/api/archive.ts
index 1163f26d..685413ea 100644
--- a/lib/api/archive.ts
+++ b/lib/api/archive.ts
@@ -1,12 +1,15 @@
import { Page, chromium, devices } from "playwright";
import { prisma } from "@/lib/api/db";
import createFile from "@/lib/api/storage/createFile";
+import sendToWayback from "./sendToWayback";
export default async function archive(linkId: number, url: string) {
const browser = await chromium.launch();
const context = await browser.newContext(devices["Desktop Chrome"]);
const page = await context.newPage();
+ sendToWayback(url);
+
try {
await page.goto(url, { waitUntil: "domcontentloaded" });
diff --git a/lib/api/sendToWayback.ts b/lib/api/sendToWayback.ts
new file mode 100644
index 00000000..c736bdd5
--- /dev/null
+++ b/lib/api/sendToWayback.ts
@@ -0,0 +1,23 @@
+import axios from "axios";
+
+export default async function sendToWayback(url: string) {
+ const headers = {
+ Accept: "text/html,application/xhtml+xml,application/xml",
+ "Accept-Encoding": "gzip, deflate",
+ Dnt: "1",
+ "Upgrade-Insecure-Requests": "1",
+ "User-Agent":
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
+ };
+
+ await axios
+ .get(`https://web.archive.org/save/${url}`, {
+ headers: headers,
+ })
+ .then((response) => {
+ console.log(response.data);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+}
diff --git a/package.json b/package.json
index 6113639f..22e782bc 100644
--- a/package.json
+++ b/package.json
@@ -28,6 +28,7 @@
"@types/nodemailer": "^6.4.8",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.7",
+ "axios": "^1.5.1",
"bcrypt": "^5.1.0",
"colorthief": "^2.4.0",
"crypto-js": "^4.1.1",
diff --git a/yarn.lock b/yarn.lock
index 78896a49..83ac24e3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1791,6 +1791,15 @@ axe-core@^4.6.2:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-4.6.3.tgz#fc0db6fdb65cc7a80ccf85286d91d64ababa3ece"
integrity sha512-/BQzOX780JhsxDnPpH4ZiyrJAzcd8AfzFPkv+89veFSr1rcMjuq2JDCwypKaPeB6ljHp9KjXhPpjgCvQlWYuqg==
+axios@^1.5.1:
+ version "1.5.1"
+ resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.1.tgz#11fbaa11fc35f431193a9564109c88c1f27b585f"
+ integrity sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==
+ dependencies:
+ follow-redirects "^1.15.0"
+ form-data "^4.0.0"
+ proxy-from-env "^1.1.0"
+
axobject-query@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-3.1.1.tgz#3b6e5c6d4e43ca7ba51c5babf99d22a9c68485e1"
@@ -2715,6 +2724,11 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787"
integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==
+follow-redirects@^1.15.0:
+ version "1.15.3"
+ resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.3.tgz#fe2f3ef2690afce7e82ed0b44db08165b207123a"
+ integrity sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==
+
for-each@^0.3.3:
version "0.3.3"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e"
@@ -4180,6 +4194,11 @@ prop-types@^15.6.0, prop-types@^15.6.2, prop-types@^15.8.1:
object-assign "^4.1.1"
react-is "^16.13.1"
+proxy-from-env@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
+ integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
+
psl@^1.1.28, psl@^1.1.33:
version "1.9.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"