Most people know websites track them. Very few can say who is tracking them on the page they're looking at right now. I wanted a small tool that answers that in one click: the companies watching this visit, whether the site is fingerprinting the device, and a simple grade from A to F.
That tool is Privacy X-Ray, a Chrome extension. The interesting constraint was that a privacy tool has to pass its own test. It can't phone home, can't keep a history, and can't become one more thing that knows where you've been.
What it watches
There are three signals, each from a different part of Chrome.
Network requests. The background service worker listens to webRequest and checks every request a page makes against a list of about a hundred known tracking domains, grouped by company and category. It only observes. It never blocks or changes a request, so sites keep working.
Third-party cookies. To count cookies that other companies try to set, it needs the Set-Cookie response headers. Chrome hides those unless you ask for extraHeaders:
chrome.webRequest.onHeadersReceived.addListener(
(details) => {
const setCookies = (details.responseHeaders || [])
.filter((h) => h.name.toLowerCase() === 'set-cookie').length
// ...count them for third-party hosts only
},
{ urls: ['<all_urls>'] },
['responseHeaders', 'extraHeaders']
)It counts the headers and never reads the cookie values.
Fingerprinting. This is the part network data can't show, because fingerprinting happens inside the page's JavaScript.
Catching fingerprinting without breaking the page
The detector is a content script that runs in the page's own JavaScript world ("world": "MAIN") at document_start, before any site script. It wraps the browser APIs that fingerprinting scripts lean on and reports patterns, not every call. Reading pixels back from a canvas that had text drawn on it is a signal. Calling toDataURL on a chart is not.
The patterns it flags:
- canvas read-back after drawing text;
- text measured in 20 or more different fonts;
- asking WebGL for the unmasked graphics-card vendor or renderer;
- rendering audio offline, with no speakers involved;
- listing media devices;
- reading the battery status.
Wrapping built-in functions is risky, because some sites check whether they've been tampered with. So each wrapper keeps the original's name and length, and Function.prototype.toString is wrapped too, so a wrapped function still prints as native code:
function wrap(proto, name, makeWrapper) {
const original = proto[name]
if (typeof original !== 'function') return
const wrapper = makeWrapper(original)
Object.defineProperty(wrapper, 'name', { value: original.name })
Object.defineProperty(wrapper, 'length', { value: original.length })
disguised.set(wrapper, original)
Object.defineProperty(proto, name, {
...Object.getOwnPropertyDescriptor(proto, name), value: wrapper,
})
}Every wrapper calls straight through to the original and returns its result unchanged. It watches; it never alters what the site gets back.
A main-world script can't talk to the extension directly, so it posts a message to a second content script in Chrome's isolated world. Any script on the page can post messages too, so the bridge only accepts ones from the same window, with a known shape and a technique from a fixed list.
Manifest V3 forgets things
In Manifest V3 the background is a service worker, and Chrome stops it whenever it's idle. Anything held only in memory, like the report for each open tab, disappears with it. Each tab's report is therefore mirrored into chrome.storage.session, with saves batched so a busy page isn't writing on every request. Session storage stays on the device, is cleared when the browser closes, and each tab's entry is deleted when the tab closes. That matches the privacy promise without extra work.
The grade
Each page starts at 100. Known trackers cost points by category, from fingerprinting services (9) and data brokers (8) down to error monitoring (1). Each fingerprinting technique costs 12, third-party cookies cost up to 15 and an unencrypted page costs 15. The result maps to a grade: 90 and above is an A, under 40 is an F. The weights are a judgement call, and they live in one file so they're easy to tune.
The mistakes worth sharing
The extension announced itself. The first version of the detector set a window.__privacyXrayInstalled flag to avoid running twice. Chrome already injects a content script once per document, so the flag did nothing useful. It did let any website check whether you had a privacy extension installed, which is exactly the kind of signal fingerprinting scripts collect. It's gone.
Dropdowns closed by themselves. The popup refreshes every second while a page is still loading trackers, and each refresh rebuilt the list from scratch. Open "Third-party cookies" and it snapped shut a second later. The fix was to skip the rebuild when the report hasn't changed, and otherwise to keep open sections open and keep the scroll position. A test against a simulated page that keeps loading showed the old code closing them and the new code keeping them open.
Processing data locally doesn't mean you don't disclose it. The Chrome Web Store asks which kinds of user data an extension handles. I assumed that since nothing leaves the device, there was nothing to declare. The store's own FAQ says otherwise: you disclose how you handle user data even when it's only processed and stored on the user's device. So the listing declares web history and user activity, and the privacy policy explains that none of it is sent anywhere.
Check what your host publishes. The extension's website is plain HTML with no scripts and no third-party requests, so it would earn an A from its own extension. Its first deploy, though, served the whole repository, extension source included, because the host published the repo root instead of the site folder. One line of configuration fixed it. Opening the deployed URLs, not just the pages you meant to publish, is what caught it.
What I'd tell anyone building one
Observe, don't intercept, unless blocking is the feature. Make wrappers invisible, or sites will break and blame you. Treat Manifest V3's service worker as something that can disappear at any moment. And when the product is about privacy, audit your own footprint as strictly as the sites you're grading.