This commit is contained in:
bob.rao
2023-04-14 15:59:21 +08:00
parent e6b5c6f0af
commit c766e8808c
6 changed files with 214 additions and 0 deletions

29
background.js Normal file
View File

@@ -0,0 +1,29 @@
chrome.webRequest.onCompleted.addListener(
(details) => {
if (
details.url.includes(
"https://chat.openai.com/backend-api/conversations?"
)
) {
chrome.tabs.sendMessage(details.tabId, {
message: "conversations_data_fetched",
});
}
},
{ urls: ["<all_urls>"] }
);
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.message === "fetch_conversations_data") {
fetch(request.url)
.then((response) => response.json())
.then((data) => {
sendResponse({ data: data.items });
})
.catch((error) => {
console.error("Error fetching conversations data:", error);
});
return true;
}
});