← All examples

JavaScript Privacy outlook.com

Outlook: block tracking pixels

Detects and removes the tiny one-pixel tracking images hidden inside the message body.

Code to copy

// Blank out 1x1 tracking pixels inside the open email body
function killPixels() {
  const body = document.querySelector('div[aria-label="Message body"]');
  if (!body) { return; }
  body.querySelectorAll('img').forEach(function (img) {
    const w = img.width || parseInt(img.getAttribute('width') || '0', 10);
    const h = img.height || parseInt(img.getAttribute('height') || '0', 10);
    if ((w <= 2 && h <= 2) || /open|track|pixel|beacon/i.test(img.src)) {
      img.removeAttribute('src');
      img.style.display = 'none';
    }
  });
}
killPixels();
const obs = new MutationObserver(killPixels);
obs.observe(document.body, { childList: true, subtree: true });

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases