The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

Archive for August 15th, 2023

Bookmarklet for Archive.is to navivate to the canonical link

Posted by jpluimers on 2023/08/15

This is a follow-up to Bookmarklets for Archive.is and the WayBack Machine to go to the original page.

Archive.is has two kinds of URLs:

  1. The encoded version is the short form without any meta-information,
  2. The canonical version is a long form and has meta data about Archive date and time, and the Archived URL,

You get the first URL both after archiving and when browsing from an archived page to another archived page (if it is not archived you will go the unarchived full page URL).

For the blog I prefer the canonical version as it is way easier to check for inconsistencies: when editing like a dozen links in a blog post with both the WayBack Machine and Archive.is archival links it is easy to get an encoded one mixed up.

The cool thing is that any Archive.is saved page has the canonical URL in the HTML twice. For the above example, this is the code:

<link rel="canonical" href="https://archive.is/2022.02.22-215053/https://www.cloudflare.com/ips/">
<link rel="bookmark" href="http://archive.today/20220222215053/https://www.cloudflare.com/ips/">

I like the format of the "canonical" version best, so the JavaScript to extract that value is similar to code I wrote for Some JavaScript bookmarklets for WordPress published pages centered around navigation and IDs:

document.querySelector('link[rel="canonical"]')?.href;

I made two Bookmarklets out of it:

    1. Show the canonical URL in a prompt dialog [Wayback/ArchiveWindow.prompt() – Web APIs | MDN:
      javascript:{ prompt("Anchor", document.querySelector('link[rel="canonical"]')?.href) }
    2. Navigate to the canonical URL:
      javascript:location=document.querySelector('link[rel="canonical"]')?.href

–jeroen

Posted in archive.is / archive.today, Development, Internet, InternetArchive, JavaScript/ECMAScript, Power User, Scripting, Software Development, WayBack machine | Leave a Comment »