-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
44 lines (43 loc) · 1.44 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
35
36
37
38
39
40
41
42
43
44
try {
importScripts("./workers/todoist.js", "./workers/obsidian.js", "./config.js");
} catch (e) {
console.error(e);
}
chrome.commands.onCommand.addListener(async (command) => {
if (command === "todoist_add-task") {
const token = await getAccessToken();
if (token) {
getActiveTabInfo((tabInfo) => {
addTask(token, tabInfo.title, tabInfo.url);
});
} else {
chrome.notifications.create(null, {
type: "basic",
iconUrl: "res/todoist-128.png",
title: "Todoist error",
message: "Please sign in to Todoist first.",
});
}
} else if (command === "todoist_random-article") {
// removed from the manifest
const token = await getAccessToken();
if (token) {
openRandomTodoistArticle(token);
} else {
chrome.notifications.create(null, {
type: "basic",
iconUrl: "res/todoist-128.png",
title: "Todoist error",
message: "Please sign in to Todoist first.",
});
}
} else if (command === "obsidian_add-reference") {
createNewObsidianNote();
} else if (command === "obsidian_mark-reference") {
markReference();
} else if (command === "toggle-footnotes") {
toggleSidenotesPane();
} else {
console.error("unknown command");
}
});