first time worked

This commit is contained in:
bob.rao
2023-04-21 12:33:49 +08:00
parent c766e8808c
commit a582bd1120
12 changed files with 209 additions and 859 deletions

View File

@@ -1,28 +1,15 @@
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);
});
console.log('Sending checkedIndexes from background:', checkedIndexes);
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { type: 'checkedIndexes', checkedIndexes: checkedIndexes });
});
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.type === 'setCheckedIndexes') {
chrome.storage.local.set({ checkedIndexes: request.checkedIndexes });
} else if (request.type === 'getCheckedIndexes') {
chrome.storage.local.get(['checkedIndexes'], (result) => {
sendResponse(result.checkedIndexes || []);
});
return true;
}
});