blob: d06bd2bd250db4ff91fbb50a09bd5e6230a046b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
vimfx.listen("goWayBack", async (_, msg) => {
try {
let eUrl = encodeURIComponent(content.location)
let aUrl = `https://archive.org/wayback/available?url=${eUrl}&closest=either&status_code=200`
let res = await content.fetch(aUrl)
if (!res.ok) return msg("Network error; failed to time travel")
let json = await res.json()
let nUrl = json?.archived_snapshots?.closest?.url
if (nUrl)
content.location = nUrl
else
msg("No URLs to travel to")
} catch { msg("Failed to time travel") }
})
vimfx.listen("goWayForward", (_, msg) => {
content.location.href =
content.location.href
.replace(new RegExp("^.+://web.archive.org/web/[0-9*]+/"), "")
})
vimfx.listen("location.replace", (url, msg) => {
content.location.replace(url)
})
|