summaryrefslogtreecommitdiff
path: root/common/.vimfx/frame.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/.vimfx/frame.js')
-rw-r--r--common/.vimfx/frame.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/common/.vimfx/frame.js b/common/.vimfx/frame.js
new file mode 100644
index 0000000..d06bd2b
--- /dev/null
+++ b/common/.vimfx/frame.js
@@ -0,0 +1,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)
+})