-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackground-script.js
More file actions
39 lines (33 loc) · 1.04 KB
/
background-script.js
File metadata and controls
39 lines (33 loc) · 1.04 KB
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
35
36
37
38
39
import { load, send } from "./common.js";
const MENU_ADD = 'rsstodolist-add'
const MENU_DEL = 'rsstodolist-del'
const installContextMenu = (prefs) =>
chrome.contextMenus.removeAll(() => {
chrome.contextMenus.create({
id: MENU_ADD,
title: `Add link to feed « ${prefs.feed} »`,
contexts: ["link"]
})
chrome.contextMenus.create({
id: MENU_DEL,
title: `Remove link from feed « ${prefs.feed} »`,
contexts: ["link"]
})
chrome.contextMenus.onClicked.addListener(info => {
send(
prefs.server,
info.menuItemId === MENU_ADD,
prefs.feed,
info.linkUrl,
undefined,
undefined,
prefs.authUser,
prefs.authPass
)
})
})
load(prefs => installContextMenu(prefs))
chrome.storage.onChanged.addListener((o) => {
const prefs = o?.prefs?.newValue
if (prefs) installContextMenu(prefs)
})