Skip to content

Instantly share code, notes, and snippets.

@belkarx
Created September 25, 2023 20:25
Show Gist options
  • Select an option

  • Save belkarx/8d2ea4a0a968332648e2eb6aecd19542 to your computer and use it in GitHub Desktop.

Select an option

Save belkarx/8d2ea4a0a968332648e2eb6aecd19542 to your computer and use it in GitHub Desktop.
wayback machine bookmarklet / chatgpt
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