From 389bc716c525e87a77925ac6b259bd1206fc30e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehver=20=7C=20=E8=BF=99=E6=B0=B4=E6=80=8E=E4=B9=88?= =?UTF-8?q?=E6=B2=A1=E5=91=B3=E5=84=BF=E5=95=8A?= <75297777+Mehver@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:23:57 +0800 Subject: [PATCH 1/2] Use code discussed in issue #2 Co-authored-by: ShenHongFei --- BiliBili-EasyCopy.user.js | 36 ++++++++++++++---------------------- README.md | 6 +++++- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/BiliBili-EasyCopy.user.js b/BiliBili-EasyCopy.user.js index a3d1d11..520cd80 100644 --- a/BiliBili-EasyCopy.user.js +++ b/BiliBili-EasyCopy.user.js @@ -2,40 +2,32 @@ // @name BiliBili-EasyCopy // @name:zh-CN BiliBili-去文本复制水印 // @namespace https://github.com/TitanRGB -// @version 1.0 +// @version 1.1 // @description 去掉B站专栏中复制文本时的水印。 // @description:zh-CN 去掉B站专栏中复制文本时的水印。 -// @author https://github.com/TitanRGB +// @author https://github.com/Mehver +// @author https://github.com/ShenHongFei // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IB2cksfwAAAAlwSFlzAAAuIwAALiMBeKU/dgAABNtJREFUeJztlnlMVFcUxhG7UbvFpklTpUu6N8WhjaVNSGMT29Ta1KXVdEkXm2pLzWgpiKFCBBvbEA3GVKUbslkGlFFsLViL2AHBsKYigiKFKTAL21RnYQZlOf3O4z15PN8bBvpvX/JLhnfPPd937zn3PoKC/n80HorNZG4Fj4BwoHMn5N2bdsQSMt2c+np6BhwFbpANZqkJs2gMaAKjgJj+JCPtLrISJo2AivhK3+Ipii8C3YBk7FCK60A6cEnCjGXrz5T2q4XW140KExMrBqhxx3ELxtaA4EmEg8ECcFohzpjk4vOBRb7qobgcqtldTkllbmHC5zXDtKvYRrYvCyVzg0APZmiIzwCvA5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QndVJf+L3wGQGRBOpUzEQpmGg1uKkLaj1Zmz3RpOdjOccWgZ6lAZuF+935T8YWgYG2UCrrOECgRt08SHBgFXtiN0NckCPH/FhcObh7C4jG8hsQONh1YGSi9LocsxsoEzrqLORW8BC8B5YJ/IhWM7Hky8kJLiHVzHNq/gyWKhpINAHSe4Cq8F+MXEKWAuimDvH+AS/twIf4C/jEvDgfxZXGLkJRPgZnwl04Da18X8B6r/U4ODjpiUAAAAASUVORK5CYII= // @match http*://bilibili.com // @match http*://bilibili.com/* // @match http*://www.bilibili.com // @match http*://www.bilibili.com/* -// @license MPL-2.0 -// @license^ Mozilla Public License 2.0 +// @license Mozilla Public License 2.0; MPL-2.0 // @charset UTF-8 // @homepageURL https://github.com/SynRGB/BiliBili-EasyCopy // @contributionURL https://github.com/SynRGB/BiliBili-EasyCopy -// @copyright Copyright © 2022-PRESENT, TitanRGB (https://github.com/TitanRGB) // ==/UserScript== -(function() { +(function () { 'use strict'; - // 使用 setTimeout 保证事件监听器在原有监听器之后执行 - setTimeout(() => { - const content = document.querySelector('body'); - content.addEventListener('copy', (event) => { - event.stopImmediatePropagation(); // 阻止其他监听器继续执行 - event.preventDefault(); // 阻止默认复制行为 - - // 从选区中获取被复制的文本,而不包含水印 - const selection = window.getSelection(); - const textToCopy = selection.toString(); - - // 将未添加水印的文本设置到剪贴板 - event.clipboardData.setData('text/plain', textToCopy); - }, true); - }, 0); + // 此实现参考自 Issue #2 中 @ShenHongFei 的代码 + document.querySelector('body').addEventListener( + 'copy', + event => { + event.stopImmediatePropagation(); + }, + true + ); })(); -console.log("JS script BiliBili-EasyCopy (BiliBili-去文本复制水印) loaded. See more details at https://github.com/SynRGB/BiliBili-EasyCopy"); +console.log("Userscript BiliBili-EasyCopy (BiliBili-去文本复制水印) loaded. See more details at https://github.com/SynRGB/BiliBili-EasyCopy"); diff --git a/README.md b/README.md index c404163..b228b1b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
-

BiliBili-去文本复制水印 v1.0

+

BiliBili-去文本复制水印 v1.1

GitHub GreasyFork @@ -16,3 +16,7 @@ ``` 这个脚本可以帮你去除这些水印。复制的是啥就是啥。 + +## 贡献者 + +- @ShenHongFei 在 Issue #2 中提供了更简洁的实现方式 From 187877cd24ff5b9a1cace4faef0299e9c77a2c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehver=20=7C=20=E8=BF=99=E6=B0=B4=E6=80=8E=E4=B9=88?= =?UTF-8?q?=E6=B2=A1=E5=91=B3=E5=84=BF=E5=95=8A?= <75297777+Mehver@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:28:29 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b228b1b..b6458c4 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,4 @@ ## 贡献者 -- @ShenHongFei 在 Issue #2 中提供了更简洁的实现方式 +- [GitHub@ShenHongFei](https://github.com/ShenHongFei) 在 Issue [#2](https://github.com/SynRGB/BiliBili-EasyCopy/issues/2) 中提供了更简洁的实现方式