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

Function PlasmoOverlay

contents/luogu.tsx:30–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

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