Skip to main content
  1. Miscellaneous/

Bulk Quote Extraction

·311 words·2 mins
Quotes - This article is part of a series.
Part 2: This Article

Recently, I was updating the quotes page on this site and I came across an unusual issue. For the past ~10 years of my life, I’ve been passively collecting quotes that I find I like. A few years ago, I installed the Momentum extension and set it up to provide me with a daily quote. Most of it’s quotes don’t resonate, but occasionally it has some quotes that I enjoy.

You can see your previous quote history by going through the list of previous quotes, but this was tedious. My previous process had been to scroll, find the ones I liked, copy, and edit their formatting for markdown. I wanted to extract all the quotes and simply remove the ones I didn’t like. Initially I thought they would be stored in plaintext on the disk, so I used the following grep command to find them: grep -rli "Steve Jobs" /mnt/c/Users/Hiller/AppData/Local/BraveSoftware/Brave-Browser/User\ Data/Default/Extensions/laookkfknpbbblfpciffpaejjkokdgca/2.26.8_0/

This did not work. A quick Google search confirmed my fear: that the quotes are stored in a LevelDB. My LevelDB parsing skills are not as strong as they should be, so I was a little afraid to use a forensic parsing tool for that. However, you can also see the output of a levelDB database in the developer pane. Describing my issue to ChatGPT, it produced the following js code for me to put into the console:

  .filter(([key]) => key.startsWith("momentum-quote-"))
  .map(([key, value]) => {
    try {
      return JSON.parse(value);
    } catch {
      return null;
    }
  })
  .filter(q => q && q.body)
  .sort((a, b) => (a.forDate || "").localeCompare(b.forDate || ""))
  .map(q => `>${q.body}\n>\n> -${q.source || "Unknown"}`)
  .join("\n\n");

const blob = new Blob([quotes], { type: "text/plain" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "momentum-quotes.txt";
a.click();
URL.revokeObjectURL(url);

It worked perfectly first try. I got all my quotes markdown formatted in a regular text file. Thanks, ChatGPT!

Hiller Hoover
Author
Hiller Hoover
Quotes - This article is part of a series.
Part 2: This Article