Created
March 15, 2017 20:55
-
-
Save kenbellows/83fd69021881d829c8e34ee755cea147 to your computer and use it in GitHub Desktop.
Bookmarklet: See archive.com's most recent copy of the current page from the Wayback Machine
This file contains 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
// minified code for pasting into a bookmarklet: | |
javascript:(function(){var a="https://web.archive.org/web/";if(window.loadTimeData)location.href=a+window.loadTimeData.data_.summary.failedUrl;else document.location=a+document.location})() | |
// full, unminified code with comments | |
/** | |
* Summary: | |
* Append the current location URL to a base Archive.org Wayback Machine URL and navigate there | |
* | |
* Example: | |
* Hacker News is currently down for maintenance, so you want to check out the most recent saved copy of the HN front page | |
* 1. Navigate to http://news.ycombinator.com; oh no, 404 | |
* 2. Ask for most recent archived version of HN | |
* desired_url = http://news.ycombinator.com | |
* archive_base_url = | |
* new_url = archive_base_url + desired_url | |
* = https://web.archive.org/web/http://news.ycombinator.com | |
* 3. Archive.org redirects to a copy saved yesterday morning, yay content! | |
*/ | |
(function(){ | |
// archive.org base URL | |
// note: the the path segment following /web/ determines the wayback machine's search behavior; basically there are 4 cases: | |
// * URL immediately follows with no path segment between, .../web/<URL>: just take me to the most recent saved copy | |
// * bare asterisk before the URL, .../web/*/<URL>: show me a listing of every copy ever saved | |
// * partial date in yyyyMMddHHmmss format, followed by an asterisk: show me a all copies whose dates match the pattern; examples: | |
// .../web/201503*/<URL> show me all saved copies of <URL> from March 2015 | |
// .../web/20000101*/<URL> show me all saved copies of <URL> from New Years Day 2000 | |
// * complete date string with no asterisk: take me to the nearest copy fillowing the specified date; examples: | |
// .../web/20000101000000/<URL> take me to the first copy on New Years Day 2000 | |
var archive = "https://web.archive.org/web/"; // take me straight to the most recent saved copy of the page | |
//var archive = "https://web.archive.org/web/*/"; // show me all saved copies on a calendar | |
//var archive = "https://web.archive.org/web/2016*/"; // show me the saved copies from 2016 | |
// works in Chrome even on the "Borked" page; not tested in Firefox or other browsers | |
if (window.loadTimeData) | |
location.href = archive+window.loadTimeData.data_.summary.failedUrl; | |
// only works when the page has successfully loaded some content; won't work from browser error pages | |
else | |
document.location=archive+document.location;})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment