Skip to content

Instantly share code, notes, and snippets.

@tadwohlrapp
Forked from n-st/view-on-archive-org.js
Last active June 20, 2025 13:36
Show Gist options
  • Save tadwohlrapp/e7bac5a8f8fe4f8affc438553973fc38 to your computer and use it in GitHub Desktop.
Save tadwohlrapp/e7bac5a8f8fe4f8affc438553973fc38 to your computer and use it in GitHub Desktop.
Bookmarklet to open either the oldest or the newest available snapshot of the current page on the Internet Archive Wayback Machine (https://archive.org/)
javascript:(()=>{let u=location.href;if(u.match(/^https?:\/\//)||(u=loadTimeDataRaw?.reloadButton?.reloadUrl),null!==u&&""!==u){let o=`https://web.archive.org/web/19700101000000/${u}`,n=`https://web.archive.org/web/${new Date().toISOString().replaceAll(/\D/g,"").slice(0,-3)}/${u}`;confirm("Click »Cancel« to open the OLDEST available Snapshot.\nClick »OK« to open the NEWEST available snapshot.")?window.open(n,"_blank"):window.open(o,"_blank")}})();
(() => {
const href = location.href;
if (!href.match(/^https?:\/\//)) {
// error pages on chrome return location.href = 'chrome-error://chromewebdata/'
href = loadTimeDataRaw?.reloadButton?.reloadUrl;
}
if (href !== null && href !== "") {
const oldest = `https://web.archive.org/web/19700101000000/${href}`;
const newest = `https://web.archive.org/web/${new Date().toISOString().replaceAll(/\D/g, "").slice(0, -3)}/${href}`;
if (confirm("Click \xbbCancel\xab to open the OLDEST available Snapshot.\nClick \xbbOK\xab to open the NEWEST available snapshot.")) {
window.open(newest, "_blank");
}
else {
window.open(oldest, "_blank");
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment