MCPcopy Create free account
hub / github.com/027xiguapi/code-box / editQRCodeImg

Function editQRCodeImg

utils/makerQRPost.ts:9–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7}
8
9export function editQRCodeImg() {
10 const title = document.title
11 const desc = document.head.querySelector('meta[name="author"]')
12 ? document.head.querySelector<HTMLMetaElement>('meta[name="description"]')!
13 .content
14 : ""
15 const href = location.href
16 const authorDom = (document.querySelector(".author-name") ||
17 document.querySelector(".article-box__meta .item")) as HTMLElement
18 const hostname = location.hostname
19
20 const author = authorDom ? authorDom.innerText : ""
21 const encodedContent = encodeURIComponent(title)
22 const encodedAuthor = encodeURIComponent(author)
23 const encodedDesc = encodeURIComponent(desc)
24 let encodedBook = null
25 const encodedUrl = encodeURIComponent(href)
26
27 hostname.includes("csdn") && (encodedBook = encodeURIComponent("《CSDN》"))
28 hostname.includes("zhihu") && (encodedBook = encodeURIComponent("《知乎》"))
29 hostname.includes("baidu") && (encodedBook = encodeURIComponent("《百度》"))
30 hostname.includes("jianshu") && (encodedBook = encodeURIComponent("《简书》"))
31 hostname.includes("jb51") &&
32 (encodedBook = encodeURIComponent("《脚本之家》"))
33 hostname.includes("cnblogs") &&
34 (encodedBook = encodeURIComponent("《博客园》"))
35 hostname.includes("51cto") && (encodedBook = encodeURIComponent("《51CTO》"))
36 hostname.includes("juejin") && (encodedBook = encodeURIComponent("《掘金》"))
37 hostname.includes("php") &&
38 (encodedBook = encodeURIComponent("《php中文网》"))
39 hostname.includes("oschina") &&
40 (encodedBook = encodeURIComponent("《开源中国》"))
41 hostname.includes("segmentfault") &&
42 (encodedBook = encodeURIComponent("《思否》"))
43 hostname.includes("weixin") && (encodedBook = encodeURIComponent("《微信》"))
44 hostname.includes("medium") &&
45 (encodedBook = encodeURIComponent("《medium》"))
46
47 // 基础链接地址,这里假设为 example.com
48 const baseUrl = "https://code-box.fun/editor-quote?"
49 const finalUrl = `${baseUrl}content=${encodedContent}&author=${encodedAuthor}&book=${encodedBook}&url=${encodedUrl}`
50 window.open(finalUrl)
51}
52
53export default function makerQRCodeImg() {
54 const qrcodepostmaker = document.createElement("canvas")

Callers 1

ToolBoxFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected