-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
21 lines (20 loc) · 803 Bytes
/
background.js
File metadata and controls
21 lines (20 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Handle extension icon click
chrome.action.onClicked.addListener(async (tab) => {
// Check if current page is a PDF
if (tab.url.toLowerCase().endsWith('.pdf') ||
tab.url.toLowerCase().includes('.pdf?') ||
tab.url.includes('content-type=application/pdf') ||
(tab.url.includes('qbo.intuit.com') && tab.url.includes('/printchecks/print'))) {
// Open our custom viewer in a new tab
const viewerUrl = chrome.runtime.getURL('viewer.html') + '?pdf=' + encodeURIComponent(tab.url);
chrome.tabs.create({ url: viewerUrl });
} else {
// Not a PDF page
chrome.scripting.executeScript({
target: { tabId: tab.id },
function: () => {
alert('This is not a PDF page. The image overlay feature is only available for PDFs.');
}
});
}
});