how to use mozilla/readability?
i want to use reaability in my project but it seem that cannot pack correctly
and will get this error
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
}
)
![No description](https://cdn.answeroverflow.com/1198284852525543525/image.png)
![No description](https://cdn.answeroverflow.com/1198284852877852804/image.png)
0 Replies