This commit is contained in:
n4ze3m
2024-02-02 22:01:16 +05:30
parent 23e488770d
commit 28361c47e6
9 changed files with 487 additions and 17 deletions

26
src/libs/get-html.ts Normal file
View File

@@ -0,0 +1,26 @@
const _getHtml = () => {
const url = window.location.href
const html = document.documentElement.outerHTML
return { url, html }
}
export const getHtmlOfCurrentTab = async () => {
const result = new Promise((resolve) => {
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
})
if (data.length > 0) {
resolve(data[0].result)
}
})
}) as Promise<{
url: string
html: string
}>
return result
}