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

@@ -4,7 +4,7 @@ import {
isTweet,
isTwitterTimeline,
parseTweet,
parseTwitterTimeline,
parseTwitterTimeline
} from "@/parser/twitter"
import { isGoogleDocs, parseGoogleDocs } from "@/parser/google-docs"
import { cleanUnwantedUnicode } from "@/utils/clean"
@@ -24,18 +24,35 @@ const _getHtml = () => {
export const getDataFromCurrentTab = 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 },
func: _getHtml
const data = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: _getHtml
})
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: _getHtml
})
if (data.length > 0) {
resolve(data[0].result)
}
})
}
}) as Promise<{
url: string
content: string