MCPcopy
hub / github.com/027xiguapi/code-box / PlasmoOverlay

Function PlasmoOverlay

contents/segmentfault.tsx:40–122  ·  view source on GitHub ↗
({ anchor })

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

useParseMarkdownFunction · 0.90
useEditMarkdownFunction · 0.90
useCssCodeHookFunction · 0.85
sendMethod · 0.80
editMarkdownFunction · 0.70
downloadMarkdownFunction · 0.70
downloadHtmlFunction · 0.70
downloadPdfFunction · 0.70

Tested by

no test coverage detected