-
Notifications
You must be signed in to change notification settings - Fork 1
/
chatgpt_injector.js
38 lines (33 loc) · 988 Bytes
/
chatgpt_injector.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
chrome.storage.local.get("copiedText", (result) => {
if (result.copiedText) {
const injectText = () => {
const inputDiv = document.querySelector("#prompt-textarea");
if (inputDiv) {
try {
const pTag = inputDiv.querySelector("p");
if (pTag) {
pTag.textContent = result.copiedText;
}
setTimeout(() => {
const sendButton = document.querySelector(
'[data-testid="send-button"]'
);
if (sendButton) {
sendButton.click();
chrome.storage.local.remove("copiedText");
} else {
console.log("Cannot find the send button");
}
}, 500);
} catch (error) {
console.error("Error injecting text", error);
}
} else {
console.log("#prompt-textarea not found");
setTimeout(injectText, 500);
}
};
// 초기 시도
injectText();
}
});