how to use mozilla/readability?

i want to use reaability in my project but it seem that cannot pack correctly
import { Readability } from "@mozilla/readability"

console.log("background script loaded")
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "sampleContextMenu",
title: "Sample Context Menu",
contexts: ["all"]
})
})

chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId == "sampleContextMenu") {
chrome.scripting.executeScript(
{
target: {
tabId: tab.id
},
world: "MAIN",
func: () => {
const doc = window.document.body.innerHTML
document.documentElement
const r = new Readability(window.document)
console.log(r)
return {
doc: doc
}
}
},
(res) => {
const r = res[0].result
}
)
import { Readability } from "@mozilla/readability"

console.log("background script loaded")
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "sampleContextMenu",
title: "Sample Context Menu",
contexts: ["all"]
})
})

chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId == "sampleContextMenu") {
chrome.scripting.executeScript(
{
target: {
tabId: tab.id
},
world: "MAIN",
func: () => {
const doc = window.document.body.innerHTML
document.documentElement
const r = new Readability(window.document)
console.log(r)
return {
doc: doc
}
}
},
(res) => {
const r = res[0].result
}
)
and will get this error
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server