-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
35 lines (33 loc) · 1.29 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
chrome.commands.onCommand.addListener((command) => {
if (command === "click_new_chat") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
const activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {
action: "clickElement",
selector: "nav>a:first-of-type",
});
});
} else if (command === "click_stop_or_regenerate") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
const activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {
action: "clickElement",
selector: "form>div:first-of-type>div:first-of-type>button",
});
});
} else if (command === "copy_last_text") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
const activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {
action: "copyElementText"
});
});
} else if (command === "focus_to_input") {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
const activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {
action: "focusToInput"
});
});
}
});