-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
31 lines (28 loc) · 1006 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Execute content script when the extension icon is clicked
chrome.action.onClicked.addListener((tab) => {
chrome.notifications.create({
type: "basic",
iconUrl: "/img/icon.png",
title: "OpenPGP Email Lookup",
message: "Looking up PGP keys for " + tab.url
});
chrome.scripting.executeScript({
target: {tabId: tab.id},
files: ['content.js']
});
});
// Listen for messages from content.js
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
// Show a notification if the PGP key has been copied to the clipboard
if (message.id === 'pgpKeyCopied') {
const email = message.email;
const pgpKey = message.pgpKey;
chrome.notifications.create({
type: "basic",
iconUrl: "/img/icon.png",
title: "OpenPGP Email Lookup",
message: "The PGP key for " + email + " has been copied to the clipboard."
});
sendResponse("Success!");
}
});