增加获取微信封面

This commit is contained in:
fzk
2025-02-06 09:17:40 +08:00
parent b8732cbf76
commit 49e72ea9ee
13 changed files with 41 additions and 6 deletions

View File

@@ -183,4 +183,4 @@ https://www.code-box.fun/
![img](https://raw.githubusercontent.com/027xiguapi/code-box/main/public/wx/qrcode_wx.jpg)
![u_wx](https://raw.githubusercontent.com/027xiguapi/code-box/blob/main/public/wx/u_wx.jpg)
![u_wx](https://github.com/027xiguapi/code-box/blob/main/public/wx/u_wx.jpg)

View File

@@ -181,4 +181,4 @@ Directly download and install:
![img](https://raw.githubusercontent.com/027xiguapi/code-box/main/public/wx/qrcode_wx.jpg)
![img](https://raw.githubusercontent.com/027xiguapi/code-box/main/public/wx/u_wx.jpg)
![img](https://github.com/027xiguapi/code-box/blob/main/public/wx/u_wx.jpg)

View File

@@ -1,3 +1,7 @@
import { DownloadOutlined, StarTwoTone } from "@ant-design/icons"
import { sendToContentScript } from "@plasmohq/messaging"
import CssCode from "~component/items/cssCode"
import DownloadHtml from "~component/items/downloadHtml"
import DownloadImages from "~component/items/downloadImages"
@@ -8,6 +12,12 @@ import ShowTag from "~component/items/showTag"
import { i18n } from "~tools"
export default function Weixin() {
async function getThumbMedia() {
sendToContentScript({
name: `weixin-getThumbMedia`
})
}
return (
<fieldset>
<legend>{i18n("weixinConfig")}</legend>
@@ -18,6 +28,13 @@ export default function Weixin() {
<DownloadHtml name="weixin" />
<DownloadPdf name="weixin" />
<DownloadImages name="weixin" />
<div className="item download" onClick={getThumbMedia}>
<span>
<StarTwoTone twoToneColor="#eb2f96" style={{ marginRight: "5px" }} />
{i18n("getThumbMedia")}
</span>
<DownloadOutlined style={{ color: "#52c41a", fontSize: "16px" }} />
</div>
</fieldset>
)
}

View File

@@ -64,6 +64,12 @@ const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
if (req.name == "weixin-downloadImages") {
await downloadImages(req.body?.onProgress)
}
if (req.name == "weixin-getThumbMedia") {
const thumbMediaUrl = document.querySelector<HTMLMetaElement>(
'meta[property="og:image"]'
).content
thumbMediaUrl && window.open(thumbMediaUrl)
}
})
async function downloadImages(

View File

@@ -21,7 +21,7 @@ import { Print } from "~utils/print"
import Turndown from "~utils/turndown"
export const config: PlasmoCSConfig = {
matches: ["https://*.zhihu.com/*"]
matches: ["https://*.zhihu.com/p/*"]
}
const turndownService = Turndown()

View File

@@ -193,5 +193,8 @@
},
"fullPageScreenshot": {
"message": "Full Page Screenshot"
},
"getThumbMedia": {
"message": "get Thumb Media"
}
}

View File

@@ -196,5 +196,8 @@
},
"fullPageScreenshot": {
"message": "全页面截图"
},
"getThumbMedia": {
"message": "获取封面"
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "code-box",
"displayName": "__MSG_extensionName__",
"version": "1.0.8",
"version": "1.0.9",
"description": "__MSG_extensionDescription__",
"author": "027xiguapi. <458813868@qq.com>",
"scripts": {

BIN
public/en/1400x560.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
public/en/440x280.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -23,16 +23,22 @@
width: 20%;
}
p {
font-size: 4em;
font-size: 2em;
color: #000;
font-family: fantasy;
}
div {
font-size: 1em;
color: #666;
font-family: fantasy;
}
</style>
</head>
<body>
<div>
<img src="./128x128.png" alt="logo" />
<p>codebox-一键复制代码/下载文章</p>
<p>codebox</p>
<div>One-click Code Copying/Downloading Articles</div>
</div>
</body>
</html>

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB