Skip to content

Commit fc41008

Browse files
committed
create chrome extension
1 parent d126e1f commit fc41008

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

chrome/background.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
async function quickAdd(data) {
2+
const text = data.selectionText;
3+
const endpoint = 'https://timkovi.ch/rip_quick_add_api';
4+
5+
const response = await fetch(endpoint, {
6+
method: 'POST',
7+
headers: {
8+
'Accept': 'application/json',
9+
'Content-Type': 'application/json',
10+
},
11+
body: JSON.stringify({text})
12+
});
13+
14+
const url = (await response.json()).url;
15+
chrome.tabs.create({url});
16+
}
17+
18+
chrome.runtime.onInstalled.addListener(() => {
19+
chrome.contextMenus.create({
20+
id: 'id',
21+
title: 'Add to calendar: "%s"',
22+
contexts: ['selection'],
23+
});
24+
25+
chrome.contextMenus.onClicked.addListener(quickAdd);
26+
});

chrome/icon_128.png

3.96 KB
Loading

chrome/icon_16.png

735 Bytes
Loading

chrome/icon_32.png

1.21 KB
Loading

chrome/icon_48.png

1.86 KB
Loading

chrome/manifest.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Rip Quick Add",
3+
"description": "Quickly create Google calendar events from natural language.",
4+
"version": "1.0",
5+
"manifest_version": 3,
6+
"permissions": [
7+
"contextMenus"
8+
],
9+
"host_permissions": [
10+
"https://timkovi.ch/rip_quick_add_api"
11+
],
12+
"background": {
13+
"service_worker": "background.js"
14+
},
15+
"icons": {
16+
"16": "icon_16.png",
17+
"32": "icon_32.png",
18+
"48": "icon_48.png",
19+
"128": "icon_128.png"
20+
}
21+
}

0 commit comments

Comments
 (0)