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