Reading research on the web has always had a core frustration: when you find the text you were looking for, you want it to stay highlighted while you read the context around it. Firefox’s native find bar highlights text while you’re actively searching, but the moment you close it, the highlighting disappears. ContextHighlight solved this by letting users select text and make the highlight stick — persistently marking up the page for as long as they needed.

The extension was part of the Palancar suite hosted at palancar.net, active during the Firefox 1.x through 3.x era. For researchers, students, and anyone doing careful reading on the web, it was one of those tools that, once you’d used it, was hard to do without.

What ContextHighlight Was

ContextHighlight added a right-click option that let users select text on any webpage and highlight it in a chosen color. Unlike the find bar’s temporary highlighting, ContextHighlight’s markup persisted on the page until you navigated away or explicitly removed it. You could highlight multiple passages in different colors, building up a visual reading layer on top of the page’s original content.

The primary use cases:

Research and reading. Academics and students highlighted key passages while reading papers or articles, letting them scan back across a long page to find the important parts without re-reading.

Comparison work. Highlighting matching terms across different sections of a page helped identify patterns, repetitions, or contradictions.

Cross-reference. When reading technical documentation, highlighting the term being defined and all instances where it appeared made the document structure visible.

The extension also integrated with Firefox’s own search. After running a find-bar search, ContextHighlight could convert the current search highlighting into a persistent color highlight — a workflow that let users mark up a document based on a search query and then close the find bar while retaining the visual markup.

ContextHighlight was listed on addons.mozilla.org and referenced in Firefox productivity roundups. The palancar.net page for the extension received backlinks from a range of Firefox resource sites.

How It Worked Technically

ContextHighlight used Firefox’s XUL framework to modify the DOM of pages the user was reading. The core technique was Range-based text highlighting: selecting a text range and wrapping it in a <span> element with a background-color style.

The technical workflow:

  1. The user selected text on the page, then right-clicked to choose the highlight option (or a keyboard shortcut triggered it)
  2. The extension retrieved the current selection via window.getSelection() and created a DOM Range from it
  3. It then used Range.surroundContents() or, for more robust handling of partial selections, iterated through the range’s text nodes wrapping each in a styled <span>
  4. Each highlighted span received a CSS class and inline style for the chosen color

Partial selection handling was the genuinely difficult part. When a user’s selection spanned multiple elements — crossing paragraph boundaries, span tags, link text, or partially inside a list item — simple surroundContents() would throw an exception because the range crossed element boundaries. Robust highlighting implementations had to split text nodes and reconstruct the DOM structure around the selection.

Later versions also needed to handle dynamic pages where highlighted content might be re-rendered by the page’s own JavaScript, destroying the injected spans.

The find-bar integration used Firefox’s internal _find service to get the current search string and then ran a separate DOM search pass to locate and highlight matching text nodes — essentially a simplified text scanner.

Documentation for the DOM Range API, which underlies all web page text highlighting, is at developer.mozilla.org/en-US/docs/Web/API/Range.

Why It Was Discontinued

The same trajectory that ended other Palancar XUL extensions applied here. Firefox 57’s Quantum release in November 2017 ended XUL/XPCOM extension support, and ContextHighlight — like its siblings in the Palancar suite — was not rewritten for the WebExtensions API.

There were also increasing native browser alternatives for the core use case. Firefox’s built-in PDF reader included real annotation tools. The web itself had evolved: many research platforms (Google Scholar, JSTOR, PubMed) added their own highlighting and annotation systems, reducing the need for a browser-level tool.

Additionally, several more feature-complete annotation and highlighting extensions had appeared on addons.mozilla.org by 2015-2017, offering cloud sync, export, and collaborative features that a simple local-only highlighter couldn’t match. The niche ContextHighlight occupied had been absorbed from both directions: browser-native features from below, more capable third-party annotation tools from above.

What Replaced It

Browser-native highlighting. Modern Firefox (version 120+) includes a “Find in Page” bar that highlights all instances of a search term in a distinct color while it’s open. While this isn’t persistent, it serves the “scan and locate” use case well.

Firefox also introduced multi-highlight support in its find bar starting with Firefox 110 — different search terms can be highlighted in different colors simultaneously, which addresses part of what ContextHighlight provided.

Current WebExtension alternatives:

  • Easy Highlighter — persistent text highlighting with color choice, close to ContextHighlight’s core behavior
  • Weava Highlighter — web and PDF highlighting with cloud sync, organization, and export
  • Liner — highlights web and PDF content with optional sharing

Annotation platforms. For research workflows specifically:

If You’re Building Something Similar Today

Persistent DOM highlighting in a WebExtension uses content scripts and the Selection/Range API. The basic approach:

// content.js
browser.runtime.onMessage.addListener((message) => {
  if (message.action === 'highlight') {
    highlightSelection(message.color);
  }
});

function highlightSelection(color) {
  const selection = window.getSelection();
  if (!selection.rangeCount || selection.isCollapsed) return;

  const range = selection.getRangeAt(0);
  
  // Handle cross-element selections
  const fragment = range.extractContents();
  const span = document.createElement('span');
  span.style.backgroundColor = color;
  span.dataset.highlight = 'true';
  span.appendChild(fragment);
  range.insertNode(span);
  
  selection.removeAllRanges();
}

The extractContents() + insertNode() pattern handles cross-element ranges more reliably than surroundContents(). The full Range API reference is at developer.mozilla.org/en-US/docs/Web/API/Range.

For persistence across page loads — something ContextHighlight did not attempt in its basic form — you’d need to serialize the range location (using an XPath or text-offset scheme) and store it via browser.storage.local, then re-apply it on subsequent page loads. This is the core technical challenge that distinguishes simple page-highlighting from a full annotation system.

For the context menu integration:

// manifest.json
{
  "permissions": ["contextMenus", "storage", "activeTab"],
  "content_scripts": [{"matches": ["<all_urls>"], "js": ["content.js"]}]
}

The contextMenus API documentation at developer.mozilla.org covers adding the right-click entry point.

The Annotation Layer That Wasn’t

ContextHighlight operated entirely locally — no sync, no export, no collaboration. When you navigated away, your highlights were gone. This limited its utility for deep research workflows, but it also meant it was simple, fast, and raised no privacy concerns about what you were reading and marking.

As annotations have moved to cloud services with sync and sharing, that local-only model has become rarer. For users who want to highlight text on a page without that data leaving their browser, a simple local-storage WebExtension is actually a reasonable privacy choice. ContextHighlight’s design philosophy — small, single-purpose, zero server dependency — is worth preserving even as the technical platform has evolved.

The original palancar.net extension page can be explored at web.archive.org.