I want to see if the current tab is a PDF file from a background page.
I can check the url for .pdf at the end but there are some PDF files that don\'t have that.
You can evaluate the property document.contentType on the current tab.
Here is an example on browserAction :
chrome.browserAction.onClicked.addListener(() => {
chrome.tabs.getSelected((tab) => {
chrome.tabs.executeScript(tab.id, { code: 'document.contentType' }, ([ mimeType ]) => {
alert(mimeType);
});
})
});
This property returns the MIME type that the document is being rendered as, not the Content-Type header (no information about the charset).