JavaScript bookmarklet to replace part of the WayBack machine URL
Posted by jpluimers on 2023/05/23
Quite often while saving a URL in the WayBack Machine, the response often is headed “Sorry” with non-descriptive “Job failed”.
In the background however, at least half of those times the job actually succeeded.
Some periodes that success rate was way lower as the archival job didn’t start with a GET request. The workaround was to use a POST request, see I want to check out how to do POST requests using bookmarklets in order to save URLs to the WayBack machine and [Archive] Jeroen Wiert Pluimers on Twitter: “Does anyone why the @waybackmachine has a lot of job failed and 404 errors over the last few days? … and … just returned a 404; most of my archivals the last few days failed or had to be retried at least half a dozen times to succeed. …” / Twitter
The error message in both “Job failed” cases is the same, so it makes sense to differ between the first case (job started and complete, but web interface failed to get that) and the latter (job didn’t even start) by doing the below URL replacement with a bookmarklet:
- from: https://web.archive.org/save/https://stackoverflow.com/questions/2689553/bookmarklet-to-edit-current-url/2689581#2689581
- to: https://web.archive.org/web/*/https://stackoverflow.com/questions/2689553/bookmarklet-to-edit-current-url/2689581#2689581
And indeed this bookmarklet does it (with the same above bolded parts):
javascript:(function() {window.location=window.location.toString().replace(/^https:\/\/web\.archive\.org\/save\/http/,'https://web.archive.org/web/*/http');})()
It can even be simpler (but maybe not fully conformant to specs):
javascript:location=location.href.replace(/^https:\/\/web\.archive\.org\/save\/http/,'https://web.archive.org/web/*/http')
A bookmarklet that goes to the latest rendered saved version (sometimes saved versions have not been rendered yet, so you get the latest available render):
- from: https://web.archive.org/save/https://stackoverflow.com/questions/2689553/bookmarklet-to-edit-current-url/2689581#2689581
- to: https://web.archive.org/web/30000000000000/https://stackoverflow.com/questions/2689553/bookmarklet-to-edit-current-url/2689581#2689581
javascript:location=location.href.replace(/^https:\/\/web\.archive\.org\/save\/http/,'https://web.archive.org/web/30000000000000/http')
The WayBack Machine uses a 14-position ID and tries to find the render that is the most close by. This is the format of the ID:
yyyymmddhhmmss
This is granular enough, as the WayBack Machine only allows new saves that are usually 30+ minutes apart.
Some thoughts
I am always surprised where JavaScript requires which quotes and where it can do without. The above is an example of this.
Via [Wayback/Archive] javascript bookmarklet replace part of url – Google Search:
- [Wayback/Archive] google chrome – Modify URL using Javascript bookmarklet – Super User (thanks [Wayback/Archive] jmt and [Wayback/Archive] lscherber)
- [Wayback/Archive] javascript – Bookmarklet to edit current URL – Stack Overflow (thanks [Wayback/Archive] kennytm, [Wayback/Archive] garymc and [Wayback/Archive] kim3er)
–jeroen
Leave a Reply