-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
34 lines (30 loc) · 1.08 KB
/
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
32
33
34
// Listen for messages from content script
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log(message);
let msgText = message.message;
let title = `copyGPT-notification-${Date.now()}`
switch (message.type) {
case 'copy':
chrome.notifications.create(`copyGPT-notification-${Date.now()}`, {
type: 'basic',
iconUrl: '/copy.png',
title: 'CopyGPTMarkdown',
message: msgText,
priority: 2
})
const content = msgText.replace(/\n/g, '\n> ');
const markdown = `> ${content.replace(/\n/g, '\n> ')}`;
console.log(markdown);
break;
case 'notification':
chrome.notifications.create(`copyGPT-notification-${Date.now()}`, {
type: 'basic',
iconUrl: '/copy.png',
title: 'CopyGPTMarkdown',
message: "message from content script",
priority: 2
})
default:
break;
}
});