few bug fixes

This commit is contained in:
n4ze3m
2024-05-12 11:38:01 +05:30
parent f9f621c920
commit 79e2013fbd
7 changed files with 225 additions and 243 deletions

View File

@@ -95,19 +95,36 @@ const getGoogleDocs = () => {
export const parseGoogleDocs = async () => {
const result = new Promise((resolve) => {
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
const tab = tabs[0]
if (import.meta.env.BROWSER === "chrome") {
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
const tab = tabs[0]
const data = await chrome.scripting.executeScript({
target: { tabId: tab.id },
world: "MAIN",
func: getGoogleDocs
const data = await chrome.scripting.executeScript({
target: { tabId: tab.id },
world: "MAIN",
func: getGoogleDocs
})
if (data.length > 0) {
resolve(data[0].result)
}
})
} else {
browser.tabs
.query({ active: true, currentWindow: true })
.then(async (tabs) => {
const tab = tabs[0]
if (data.length > 0) {
resolve(data[0].result)
}
})
const data = await browser.scripting.executeScript({
target: { tabId: tab.id },
func: getGoogleDocs
})
if (data.length > 0) {
resolve(data[0].result)
}
})
}
}) as Promise<{
content?: string
}>