From 78b72c4e0be0aadaf271e4b2aaa7be215d5a8b2a Mon Sep 17 00:00:00 2001 From: fzk <458813868@qq.com> Date: Fri, 19 Jul 2024 09:43:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E5=85=A5=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +++++++++++- component/content.tsx | 19 +++++++++++++++++++ component/custom.tsx | 34 ++++++++++++++++++++++++++++++++++ contents/custom.tsx | 22 ++++++++++++++++++++++ contents/jb51.tsx | 8 ++------ index.css | 35 +++++++++++++++++++++++++++++------ options.tsx | 16 +++------------- package.json | 6 +++--- popup.tsx | 16 +++------------- tools.ts | 12 ++++++++++-- 10 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 component/content.tsx create mode 100644 component/custom.tsx create mode 100644 contents/custom.tsx diff --git a/README.md b/README.md index 2106922..cd6888e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,13 @@ https://github.com/027xiguapi/code-box ![img](https://raw.githubusercontent.com/027xiguapi/code-box/main/public/img.png) -### 安装方式二:源码安装 +### 安装方式二:安装包 + +1. 下载地址: https://github.com/027xiguapi/code-box/releases +2. 谷歌浏览器,从右上角菜单->更多工具->扩展程序可以进入插件管理页面,也可以直接在地址栏输入 chrome://extensions 访问 +3. 勾选开发者模式,即可以文件夹的形式直接加载插件 + +### 安装方式三:源码安装 1. clone源码 ```sh @@ -41,6 +47,10 @@ https://github.com/027xiguapi/code-box ![img-1](https://raw.githubusercontent.com/027xiguapi/code-box/main/public/img_1.png) +### 自定义 + +1. 插入自定义样式(css代码) + ### CSDN 1. 打开任意一个`CSDN`博客即可开始复制代码 diff --git a/component/content.tsx b/component/content.tsx new file mode 100644 index 0000000..19bf788 --- /dev/null +++ b/component/content.tsx @@ -0,0 +1,19 @@ +import Cnblogs from "./cnblogs" +import Csdn from "./csdn" +import Custom from "./custom" +import Jb51 from "./jb51" +import Jianshu from "./jianshu" +import Zhihu from "./zhihu" + +export default function Content() { + return ( + <> + + + + + + + + ) +} diff --git a/component/custom.tsx b/component/custom.tsx new file mode 100644 index 0000000..2f19df4 --- /dev/null +++ b/component/custom.tsx @@ -0,0 +1,34 @@ +import { useStorage } from "@plasmohq/storage/hook" + +export default function Custom() { + const [runCss, setRunCss] = useStorage("custom-runCss", (v) => + v === undefined ? false : v + ) + const [cssCode, setCssCode] = useStorage("custom-cssCode", (v) => + v === undefined ? "" : v + ) + + return ( +
+ 自定义设置 +
+ 页面插入css代码 + setRunCss(e.target.checked)} + /> + +
+
+ +
+
+ ) +} diff --git a/contents/custom.tsx b/contents/custom.tsx new file mode 100644 index 0000000..7ee9c75 --- /dev/null +++ b/contents/custom.tsx @@ -0,0 +1,22 @@ +import { useEffect } from "react" + +import { useStorage } from "@plasmohq/storage/hook" + +import { addCss } from "~tools" + +export default function Custom() { + const [runCss] = useStorage("custom-runCss") + const [cssCode] = useStorage("custom-cssCode") + + useEffect(() => { + runCss && runCssFunc() + }, [runCss]) + + /* 插入自定义css代码 */ + function runCssFunc() { + console.log("插入自定义css代码", cssCode) + addCss(cssCode) + } + + return
+} diff --git a/contents/jb51.tsx b/contents/jb51.tsx index fcd5336..206f5b5 100644 --- a/contents/jb51.tsx +++ b/contents/jb51.tsx @@ -18,14 +18,10 @@ export default function jb51() { const [copyCode] = useStorage("jb51-copyCode") useEffect(() => { - console.log("jb51 closeAds", closeAds) + console.log("jb51 status", { closeAds, copyCode }) closeAds && closeAdsFunc() - }, [closeAds]) - - useEffect(() => { - console.log("jb51 copyCode", copyCode) copyCode && copyCodeFunc() - }, [copyCode]) + }, [closeAds, copyCode]) /* 未登录复制代码 */ function copyCodeCssFunc() { diff --git a/index.css b/index.css index b90f1ea..029a2df 100644 --- a/index.css +++ b/index.css @@ -1,5 +1,20 @@ +* { + margin: 0; + padding: 0; +} + +.hide { + display: none !important; +} + +.show { + display: block !important; +} + .App { - width: 160px; + width: 190px; + margin: 0 auto; + padding: 5px 8px; } .App-header .title { @@ -18,6 +33,10 @@ font-size: 14px; } +.App-body fieldset { + padding: 5px 8px; +} + .App-body fieldset .item { display: flex; justify-content: space-between; @@ -26,12 +45,16 @@ font-size: 12px; } +.App-body fieldset .item textarea { + padding: 5px; +} + /*开关*/ -.codebox-offscreen{ +.codebox-offscreen { display: none; } -.codebox-switch{ +.codebox-switch { position: relative; display: inline-block; width: 40px; @@ -41,7 +64,7 @@ transition: all 0.3s; } -.codebox-switch::after{ +.codebox-switch::after { content: ""; position: absolute; width: 18px; @@ -53,10 +76,10 @@ transition: all 0.3s; } -input[type="checkbox"]:checked+.codebox-switch::after{ +input[type="checkbox"]:checked + .codebox-switch::after { transform: translateX(20px); } -input[type="checkbox"]:checked+.codebox-switch{ +input[type="checkbox"]:checked + .codebox-switch { background-color: #7983ff; } \ No newline at end of file diff --git a/options.tsx b/options.tsx index c0d0ab2..fe05664 100644 --- a/options.tsx +++ b/options.tsx @@ -1,12 +1,8 @@ -import Cnblogs from "./component/cnblogs" -import Csdn from "./component/csdn" -import Jb51 from "./component/jb51" -import Jianshu from "./component/jianshu" -import Zhihu from "./component/zhihu" +import Content from "./component/content" import "./index.css" -function IndexOptions() { +export default function IndexOptions() { return (
@@ -14,11 +10,7 @@ function IndexOptions() {

更方便操作网页代码

- - - - - +
) } - -export default IndexOptions diff --git a/package.json b/package.json index 0671c10..af31474 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "code-box", - "displayName": "codebox-免登录复制代码(CSDN/知乎/脚本之家/博客园)", - "version": "0.0.8", - "description": "本插件可以用于CSDN/知乎/脚本之家/博客园等网站,实现无需登录一键复制代码;支持选中代码;或者代码右上角按钮的一键复制;解除关注博主即可阅读全文提示;去除登录弹窗;去除跳转APP弹窗.", + "displayName": "codebox-免登录一键复制代码(CSDN/知乎/脚本之家/博客园)", + "version": "0.1.0", + "description": "本插件可以用于CSDN/知乎/脚本之家/博客园等网站,实现无需登录一键复制代码;支持选中代码;或者代码右上角按钮的一键复制;解除关注博主即可阅读全文提示;去除登录弹窗;去除跳转APP弹窗;页面自定义样式.", "author": "027xiguapi. <458813868@qq.com>", "scripts": { "dev": "plasmo dev", diff --git a/popup.tsx b/popup.tsx index dcec0f7..10911b7 100644 --- a/popup.tsx +++ b/popup.tsx @@ -1,12 +1,8 @@ -import Cnblogs from "./component/cnblogs" -import Csdn from "./component/csdn" -import Jb51 from "./component/jb51" -import Jianshu from "./component/jianshu" -import Zhihu from "./component/zhihu" +import Content from "./component/content" import "./index.css" -function IndexPopup() { +export default function IndexPopup() { return (