All posts →
|Also available in:DE

The power of web extensions and the web as a platform

The web is a wonderful platform. Browser extensions are a powerful way to extend what the web can do. Here is an example using WhatsApp Web and MaraDocs.

•Martin Kurtz
WhatsAppLaw firmMaraDocsWeb extension
The power of web extensions and the web as a platform

The power of web extensions

I am once again completely thrilled by the web as a platform. In recent years, the browser has become the most important program runtime, and it never ceases to amaze me what is possible in modern browsers (and in modern JavaScript frameworks such as React).

We searched for a long time for a way to import images from WhatsApp

For about two years, I have kept coming back to the question of how we can move images or documents from WhatsApp into other programs in a secure and privacy-compliant way, whether as an import or an export. WhatsApp belongs to Meta and, whether one likes it or not, it is the most widely used messenger.

What's great: Message content in WhatsApp is end-to-end encrypted.

What's not great: WhatsApp does not offer an API for receiving WhatsApp messages programmatically. In the age of modern automation tools (n8n, various LegalTech tools, MaraDocs …), that is annoying, because it means manual steps are still required to get at the documents.

What you can hardly believe: I just wrote that there is no API. That is not entirely accurate. Meta does offer an API that can be used to receive and send messages. However, it requires a WhatsApp Business account. And Meta has itself granted extensive rights of use to the content sent (and received):

From a data protection perspective, the WhatsApp Business Terms are unacceptable

Here is an excerpt from the current WhatsApp Business Terms:

No. 5 Licenses and Intellectual Property
You grant WhatsApp and its subsidiaries and affiliates a worldwide, non-exclusive, sublicensable and transferable license to use, reproduce, modify, adapt, publish, translate, create derivative works from, distribute, and publicly perform or display the business content that you upload, submit, store, send, or receive on or through our Business Services (...).
Source: WhatsApp Business Terms, accessed October 2025

I think it is obvious that importing confidential client communications through such a WhatsApp Business account is not feasible. So there is no usable API.

In other words, Meta has itself granted extensive rights of use to the content sent (and received). This means that nobody who processes personal or other confidential data of their customers or clients can use a WhatsApp Business account. And the ability to access messages or transmitted images programmatically (that is, via API) stands and falls with that account.

Note: Our browser extension (see blog article) sidesteps the dilemma described here. It uses neither an API nor a WhatsApp Business account to import images from WhatsApp, so the export is privacy-compliant.

So how do we export images from WhatsApp without a data protection disaster?

This is where they come in: web extensions, also known as browser extensions.

Browser extensions are programs that the browser loads into specific web pages after the fact and that can interact (in a very well-defined way) with the content found there.

And within its otherwise very closed and barricaded ecosystem, WhatsApp opened up a flank to its internals by creating WhatsApp Web. You can sign in at web.whatsapp.com by scanning a QR code with the WhatsApp app on your phone, and you then get all your chats in a browser window for convenient use.

And with extensions, we can reach into that browser window.

The architecture of a browser extension

The extension essentially provides three components:

  • A background script, which runs independently of any current web page
  • One content script for each page, which is "injected" into previously defined web pages and runs in their context
Webextension für Chrome-Browser: Easy Image Exporter for WhatsApp Web
Die Architektur einer Browser-Extension (Martin Kurtz)

For security reasons, individual browser tabs are strongly isolated from one another. This means that two web pages cannot communicate directly.

The extension's background script therefore acts as a messaging hub. Both the content script in web.whatsapp.com and the content script on app.maradocs.io can send messages to the background script and receive messages from it.

So when the WhatsApp content script wants to send an image to the MaraDocs content script, it packages the image into a text-encoded (Base64-encoded) message and sends it to the background script. Depending on the defined message type, the message is then forwarded accordingly.

The MaraDocs content script, in turn, waits for such messages, validates them, and passes them on (now via so-called CustomEvents) to the original MaraDocs code.

Of course, the devil is in the details: besides general validation of the data (is everything in this message correct?), data from several messages has to be reassembled (CustomEvents have a size limit of one megabyte …). What about messages that are sent twice, or messages that go missing … 100 other potential problems.

But once these individual steps are cleanly modeled and implemented, the magic trick is complete: with a single click, (multiple) image files are migrated from WhatsApp's normally closed ecosystem to MaraDocs, where they can easily be converted into proper PDF documents.

Even after an intense coding weekend, I still find this fascinating.

Our free browser extension Easy Image Exporter for WhatsApp Web makes it easier to bulk-download images from WhatsApp Web and also offers direct import into MaraDocs. We present it in detail in the linked blog article.

Subscribe to our newsletter

Stay up to date with us and receive the latest news, articles, and resources by email.

This is MaraDocs: Optimize, combine, download

The workflow is designed around the needs of everyday work in a law firm: it has to be quick and easy!

  • Drag and drop or copy and paste an email with attachments, or files, into the app
  • All attachments are extracted and analyzed automatically
  • Documents are automatically detected, cropped, and converted into searchable scans
  • PDFs are reduced in size, and text recognition is performed where necessary
  • All pages are automatically aligned and rotated according to text direction
  • Pages can be combined into new PDFs very easily
  • Renaming takes just a single click
  • Download. Done.

Intelligent document processing with MaraDocs

With MaraDocs, you transform your clients' email attachments into perfect scans. Crop, straighten, merge, text recognition, and much more.

Start free now