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

Function PlasmoOverlay

contents/baidu.tsx:30–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28export const getShadowHostId: PlasmoGetShadowHostId = () => "codebox-baidu"
29const isBaijiahao = location.hostname.includes("baijiahao")
30const PlasmoOverlay: FC<PlasmoCSUIProps> = () => {
31 const [parseContent, setParseContent] = useParseMarkdown()
32 const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true)
33 const [showTag, setShowTag] = useStorage<boolean>("baidu-showTag", true)
34 const [cssCode, runCss] = useCssCodeHook("baidu")
35 const [closeAIBox] = useStorage<boolean>("baidu-closeAIBox")
36 const [closeLog] = useStorage("config-closeLog", true)
37 const [content, setContent] = useEditMarkdown()
38
39 useEffect(() => {
40 closeLog || console.log("baidu", { closeAIBox })
41 closeAIBox && closeAIBoxFunc()
42 }, [closeAIBox])
43
44 useMessage(async (req, res) => {
45 if (req.name == "baidu-isShow") {
46 res.send({ isShow: true })
47 }
48 if (req.name == "baidu-editMarkdown") {
49 editMarkdown()
50 }
51 if (req.name == "baidu-downloadMarkdown") {
52 downloadMarkdown()
53 }
54 if (req.name == "baidu-downloadHtml") {
55 downloadHtml()
56 }
57 })
58
59 /* 删除百度AI对话框 */
60 function closeAIBoxFunc() {
61 addCss(`.wd-ai-index-pc{
62 display:none !important;
63 }`)
64 }
65
66 function getDescription() {
67 const summary = document.querySelector<HTMLMetaElement>(
68 'meta[name="description"]'
69 ).content
70 summary && prompt(i18n("getDescription"), summary)
71 }
72
73 function downloadPdf() {
74 const article = document.querySelector<HTMLElement>(
75 isBaijiahao ? "#ssr-content .EaCvy" : ".wd-ai-index-pc"
76 )
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(
86 isBaijiahao ? "#ssr-content .EaCvy" : ".wd-ai-index-pc"
87 )

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected