Created
September 25, 2023 20:25
-
-
Save belkarx/8d2ea4a0a968332648e2eb6aecd19542 to your computer and use it in GitHub Desktop.
wayback machine bookmarklet / chatgpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript: (function() { | |
| var currentUrl = window.location.href; | |
| var apiUrl = "https://archive.org/wayback/available?url=" + encodeURIComponent(currentUrl); | |
| console.log("Sending GET request to:", apiUrl); | |
| fetch(apiUrl).then(response => { | |
| console.log("Received response:", response); | |
| return response.json(); | |
| }).then(data => { | |
| console.log("Received data:", data); | |
| var archivedUrl = data["archived_snapshots"]["closest"]["url"]; | |
| if (archivedUrl) { | |
| console.log("Opening archived URL:", archivedUrl); | |
| window.open(archivedUrl, % 27_ blank % 27); | |
| } else { | |
| console.warn("No archived snapshot found."); | |
| alert("No archived snapshot found."); | |
| } | |
| }).catch(error => { | |
| console.error("Error fetching data:", error); | |
| alert("An error occurred while fetching data."); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment