diff options
author | Simon Parri <simonparri@ganzeria.com> | 2025-07-22 00:56:22 +0200 |
---|---|---|
committer | Simon Parri <simonparri@ganzeria.com> | 2025-07-22 11:49:01 +0200 |
commit | d2c331b9f036951eef062dd5141c75182375ba12 (patch) | |
tree | 325bf3c56b70ec845e8de9349f45408ed844e747 /common/.vimfx/frame.js | |
download | dotfiles-d2c331b9f036951eef062dd5141c75182375ba12.tar.gz dotfiles-d2c331b9f036951eef062dd5141c75182375ba12.zip |
Add current configuration
Diffstat (limited to 'common/.vimfx/frame.js')
-rw-r--r-- | common/.vimfx/frame.js | 24 |
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) +}) |