()
| 47 | const isPaywallbuster = location.hostname.includes("paywallbuster") |
| 48 | |
| 49 | const PlasmoOverlay: FC<PlasmoCSUIProps> = () => { |
| 50 | const [parseContent, setParseContent] = useParseMarkdown() |
| 51 | const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true) |
| 52 | const [showTag, setShowTag] = useStorage<boolean>( |
| 53 | "paywallbuster-showTag", |
| 54 | true |
| 55 | ) |
| 56 | const [cssCode, runCss] = useCssCodeHook("paywallbuster") |
| 57 | const [content, setContent] = useEditMarkdown() |
| 58 | |
| 59 | useMessage(async (req, res) => { |
| 60 | if (req.name == "paywallbuster-isShow") { |
| 61 | res.send({ isShow: true }) |
| 62 | } |
| 63 | if (req.name == "paywallbuster-editMarkdown") { |
| 64 | editMarkdown() |
| 65 | } |
| 66 | if (req.name == "paywallbuster-downloadMarkdown") { |
| 67 | downloadMarkdown() |
| 68 | } |
| 69 | if (req.name == "paywallbuster-downloadHtml") { |
| 70 | downloadHtml() |
| 71 | } |
| 72 | if (req.name == "paywallbuster-downloadPdf") { |
| 73 | downloadPdf() |
| 74 | } |
| 75 | }) |
| 76 | |
| 77 | function getDescription() { |
| 78 | const summary = document.querySelector<HTMLMetaElement>( |
| 79 | 'meta[name="description"]' |
| 80 | ).content |
| 81 | summary && prompt(i18n("getDescription"), summary) |
| 82 | } |
| 83 | |
| 84 | function downloadPdf() { |
| 85 | const article = document.querySelector<HTMLElement>("article") |
| 86 | if (article) { |
| 87 | Print.print(article, { title: articleTitle }) |
| 88 | .then(() => console.log("Printing complete")) |
| 89 | .catch((error) => console.error("Printing failed:", error)) |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | function downloadWord() { |
| 94 | const dom = document.querySelector("article") |
| 95 | saveWord(dom, articleTitle) |
| 96 | } |
| 97 | |
| 98 | function editMarkdown() { |
| 99 | const dom = document.querySelector("article") |
| 100 | setContent(dom, articleTitle) |
| 101 | } |
| 102 | |
| 103 | function downloadMarkdown() { |
| 104 | const html = document.querySelector("article") |
| 105 | const markdown = turndownService.turndown(html) |
| 106 | saveMarkdown(markdown, articleTitle) |
nothing calls this directly
no test coverage detected