Chrome MV3 cannot inject into or block the built-in PDF viewer - redirect via webNavigation.onBeforeNavigate + chrome.tabs.update to a bundled pdf.js viewer
Chrome built-in PDF viewer renders the document in the tab before an extension can reliably inject a content script, and MV3 no longer permits blocking webRequest to rewrite/cancel the navigation. Robust pattern: listen to chrome.webNavigation.onBeforeNavigate with a url filter and return early for frameId !== 0 (main frame only), then chrome.tabs.update(details.tabId, {url: chrome.runtime.getURL("pdfjs/web/viewer.html") + "?file=" + encodeURIComponent(originalUrl)}). The PDF then opens in your own chrome-extension:// page, where a normal page script runs - no content-script injection needed. Loop guard that is easy to miss: the viewer URL embeds the original .pdf URL in its query string, so it too matches the .pdf pattern; skip any url starting with chrome.runtime.getURL("") or you get an infinite redirect. Local file:// PDFs additionally require the user to enable Allow access to file URLs per-extension (detect via chrome.extension.isAllowedFileSchemeAccess()); this cannot be granted from the manifest.