Skip to main content

Bookmarklets

  • Updated

I love bookmarklets. They’re a useful way to add functionality to browsers without extensions, and to me they represent the spirit of the web that encourages exploration and tinkering. They come from a time when you could view source on any web page and see something readable, and they still work today!

These are some bookmarklets I find useful.

To add one of my bookmarklets to your own browser, drag the title link to your bookmarks bar.

Get published date of Tumblr post

Tumblr posts don’t always say when they were published, or they show the date in a vague way like “7 years ago”. This bookmarklet pops up a dialog with the exact date a post was published.

Screenshot of a Tumblr page with a modal alert dialog on top. The modal alert reads ‘This post was published on 24 September 2024’.
Source code
/* In the <head> of each Tumblr post is a block of JSON-LD (=Linked Data)
 * which has some machine-readable info about the post, e.g.
 *
 *     <script type="application/ld+json">
 *       {
 *         "@type": "SocialMediaPosting",
 *         "url": "https:\/\/example.tumblr.com\/post\/12345678\/",
 *         "datePublished": "2015-08-11T07:07:10+00:00",
 *         …
 *       }
 *     </script>
 *
 */
var jsonLdElement = document.querySelector('script[type="application/ld+json"]');
var jsonLd = JSON.parse(jsonLdElement.innerText);
var datePublished = new Date(jsonLd["datePublished"]);

/* Formats a day like "25 September 2024" */
var format = new Intl.DateTimeFormat("en-GB", {
  year: "numeric",
  month: "long",
  day: "numeric",
});

alert(`This post was published on ${format.format(datePublished)}.`);