Willem Prins

Web development and (country) life.

Facebook post data as a personal musical time machine – Part 2 (2013-2019)

This is the second and final installment of my journey through my own Facebook history to assemble a playlist of music I shared on my timeline. You can find part 1 here.

Finding out that entries in the HTML archive of my Facebook activity were not sorted chronologically

When you download your Facebook data, you can save this to your computer or other device, or give Meta permission to upload a zip file to your Google Drive or Dropbox. I found this very convenient, because it meant that I could simply download it whenever it was ready, without having to keep a browser window open. After choosing the destination, you pick the format for the download, with the options being HTML and JSON. Since I was mostly interested in browsing my archive, and not do anything with it programmatically, I chose HTML.

After unzipping the archive, you end up with a large folder structure containing various types of data. For HTML downloads, the root folder ships with a helpful start_here.html file, which serves as an entry point to the archive.
The most interesting folder, called your_facebook_activity, is also the largest: in my case, it contains 235 MBs worth of html and uploaded media files.

As I scrolled down the HTML file that contains all “posts, check-ins, photos and videos”, I discovered that the entries were not sorted chronologically. Instead of finding posts from 2013, I stumbled upon more posts and status updates from 2011, which I thought I’d already covered in my previous post!

Coming up with a solution, the old fashioned way.

Now I remembered from Wes Bos’ Beginner JavaScript course that it’s really easy to fix these kinds of problems in html documents by using JavaScript in the console. Seeing how all posts were using the exact same markup with a date string in a child element, I figured it would be fairly easy to sort the items according to this string. But my JavaScript is rusty, so my first idea was to use Google to look up how to dig down into a descendant in a comparison function.

Which brought me to a thread on Stack Overflow where the accepted answer did not yet include a way to extract a date from an item’s child node and compare & sort based on these values. That left me with a choice: dig in and refamiliarize myself with JavaScript’s way of getting values from the DOM, or… ask AI.

Asking Claude to fix a seemingly randomly ordered list of posts and updates

Remembering that it is, in fact, 2025, I realized that I could also try and solve this with an AI agent. This was also a perfect opportunity to try out the free GitHub Copilot extension in Visual Studio Code I had recently activated. To my surprise, the first prompt that I passed to Claude Sonnet 3.5 yielded a result that was sufficient to solve my problem:

Can you help me create a JS script that I can run in the browser console to sort items in a html document according to a date string inside a descendant node of each item.

The suggested code made it very easy to run the function against the classes I’d found in the archive markup.

View the code
function sortElementsByDate(parentSelector, dateSelector) {
    // Get the parent element
    const parent = document.querySelector(parentSelector);
    if (!parent) return;

    // Get all items to sort
    const items = Array.from(parent.children);

    // Sort items based on date strings
    items.sort((a, b) => {
        const dateA = new Date(a.querySelector(dateSelector)?.textContent || '');
        const dateB = new Date(b.querySelector(dateSelector)?.textContent || '');
        return dateB - dateA; // Descending order (newest first)
    });

    // Reappend items in sorted order
    items.forEach(item => parent.appendChild(item));
}

// Example usage:
// sortElementsByDate('.container', '.date-field');

For those of you who are curious what this exchange between me and Claude looked like: here is a screenshot from Visual Studio:

Screenshot of the Visual Studio Code interface for Copilot, showing Willem's original prompt about sorting DOM items and below it, a highlighted code fragment suggested by Claude Sonnet 3.5.
The solution to my problem, generated in a few seconds by Claude.

Reflecting on an unexpectedly smooth and succesful interaction with Claude

I was a bit shocked at how well this worked! From a “AI will take our jobs”-perspective, I did find some comfort knowing that my own development experience did matter here:

  • First of all, I was able to leverage my own development experience to make my request as specific as possible. I’m not sure what would have happened if I had not been able to use DOM-related concepts like ‘descendant’ and ‘node’ to ensure that Claude would understand what I was looking for.
  • Secondly, I would also not have known that I can run javascript commands in the console if had no previous experience with this.
  • Finally, knowing which class names to add to the selectors also required some knowledge of navigating the HTML structure.

Still, single-shotting a prompt to solve a problem… what a time to be alive!

Going through the second part of my post archive yielded fewer songs for the playlist than in the first part, even though the timespan was longer. In the first four years, I created 28 music-related posts linking to songs, albums and concerts. Between 2013 onwards, I only shared 16. This is no surprise though, seeing how I became far less active in 2016, the year of the US elections and the Cambridge Analytica scandal. My Facebook activity dropped to almost zero in 2018.

Videos that I could not find on Spotify or – in most cases – were simply too nice not to share

Between 2013 and 2019, I mostly shared songs on Facebook in the form of YouTube links. For a few of them, I was not able to find the recording on Spotify. And since the videos do sometimes matter, I’ll share all of the links here, in ascending chronological order:

The single track that got away from me

For some more context on the problem of expired links to YouTube videos and other sources, see Part 1. Interestingly, the metadata used to embed a preview of a video on your timeline does sometimes gets stored by Facebook. But it’s stripped from the activity archive.

That means that this YouTube link, posted without context, may or may not have been another music video shared by me.

Epilogue: in between the songs, traces of my own responses to prominent figures in recent history (and the present)

This Facebook post archive did not just enable me to time travel through my musical tastes, I also discovered that I too helped push political and commercial agendas that have thrived exactly through successful social media campaigns.

Via Facebook, I have shared content from people who would become notoriously famous a few years later: I was happy to write positively and optimistically about the intentions of Elon Musk while sharing a video of him unveiling the Tesla Power Wall in 2016. A year earlier, I shared a post by Boris Johnson about the destruction of cultural heritage in Syria by ISIS in 2015. While I must have done this because I liked how he worded his anger towards this kind of destruction and emphasized the importance of these ancient heritage sites, I fully overlooked the last paragraph of his post, in which he connects this to his political agenda of wanting a strict immigration policy in the EU.

When it comes to complex political topics, I was – and still am – naive about things I read. Being painfully aware of this, I have always been hesitant to make political statements of any kind on social media. But I’m happy that I did occasionally step outside of my ironic, music-minded comfort zone, so that years after the fact, I can read back how world events had an impact on me.

One response

  1. […] I have just published part 2 of this post. In it, I describe how I found out that my archive was not chronologically ordered at all, and how […]

Leave a Reply

Your email address will not be published. Required fields are marked *