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

Function PlasmoOverlay

contents/cnblogs.tsx:41–202  ·  view source on GitHub ↗
({ anchor })

Source from the content-addressed store, hash-verified

39export const getStyle: PlasmoGetStyle = () => TagBtnStyle()
40
41const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
42 const [parseContent, setParseContent] = useParseMarkdown()
43 const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true)
44 const [showTag, setShowTag] = useStorage<boolean>("cnblogs-showTag", true)
45 const [cssCode, runCss] = useCssCodeHook("cnblogs")
46 const [copyCode] = useStorage<boolean>("cnblogs-copyCode")
47 const [history, setHistory] = useStorage<any[]>("codebox-history")
48 const [closeLog] = useStorage("config-closeLog", true)
49 const [content, setContent] = useEditMarkdown()
50
51 useEffect(() => {
52 closeLog || console.log("cnblogs copyCode", copyCode)
53 copyCode && copyCodeFunc()
54 }, [copyCode])
55
56 useMessage(async (req, res) => {
57 if (req.name == "cnblogs-isShow") {
58 res.send({ isShow: true })
59 }
60 if (req.name == "cnblogs-editMarkdown") {
61 editMarkdown()
62 }
63 if (req.name == "cnblogs-downloadMarkdown") {
64 downloadMarkdown()
65 }
66 if (req.name == "cnblogs-downloadHtml") {
67 downloadHtml()
68 }
69 if (req.name == "cnblogs-downloadPdf") {
70 downloadPdf()
71 }
72 })
73
74 // 功能一: 修改复制按钮,支持一键复制
75 function copyCodeFunc() {
76 const toolbars = document.querySelectorAll<HTMLElement>(
77 ".cnblogs_code_toolbar"
78 )
79
80 toolbars.forEach((toolbar) => {
81 const button = document.createElement("button")
82 button.innerText = i18n("copy")
83 button.style.float = "right"
84 button.title = i18n("copyCode")
85 button.classList.add("copy-btn")
86
87 toolbar.appendChild(button)
88 })
89
90 const buttons = document.querySelectorAll<HTMLElement>(
91 ".cnblogs_code_toolbar .copy-btn"
92 )
93
94 buttons.forEach((btn) => {
95 // 移除点击事件
96 btn.setAttribute("onclick", "")
97
98 // 克隆按钮

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected