Skip to content

Commit

Permalink
Merge pull request #3 from SynRGB/issue2
Browse files Browse the repository at this point in the history
Issue2
  • Loading branch information
Mehver authored Jul 12, 2024
2 parents 2039de3 + 187877c commit 04c9fa4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
36 changes: 14 additions & 22 deletions BiliBili-EasyCopy.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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+Ipii8C3YBk7FCK60A6cEnCjGXrz5T2q4XW140KExMrBqhxx3ELxtaA4EmEg8ECcFohzpjk4vOBRb7qobgcqtldTkllbmHC5zXDtKvYRrYvCyVzg0APZmiIzwCvA5uK+BWwRhKfBRrkq3Ym5pPR0DwcWz3Ek/9KqPD2Ve05OeqLzyV5HPC1pRSt0DDwArCoiF8Gm8BMycC7UsLRDVnUnlLE9W75rHbkIwQ9CkILf2qch7GdiHFKsSOIrfvGRIknPb0cpxB/CDSoiPvA+qviooEsTujZZKCy76s4YRsCwoGyR0LAW8DDsQV5zUJZxMSl4AZR/Eaxy5XivJsbuD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JRPgZnwl04Da18X8B6r/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");
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<img src="https://github.com/SynRGB/BiliBili-EasyCopy/raw/main/%23README/icon/256.png" width="20%"/>
<h1>BiliBili-去文本复制水印 <code>v1.0</code></h1>
<h1>BiliBili-去文本复制水印 <code>v1.1</code></h1>
<p>
<a href='https://github.com/SynRGB/BiliBili-EasyCopy'><img src="https://img.shields.io/badge/-GitHub-3A3A3A?style=flat&amp;logo=GitHub&amp;logoColor=white" referrerpolicy="no-referrer" alt="GitHub"></a>
<a href='https://greasyfork.org/zh-CN/scripts/464155-bilibili-easycopy'><img src="https://img.shields.io/badge/-GreasyFork-670000?style=flat&amp;logo=tampermonkey&amp;logoColor=white" referrerpolicy="no-referrer" alt="GreasyFork"></a>
Expand All @@ -16,3 +16,7 @@
```

这个脚本可以帮你去除这些水印。复制的是啥就是啥。

## 贡献者

- [GitHub@ShenHongFei](https://github.com/ShenHongFei) 在 Issue [#2](https://github.com/SynRGB/BiliBili-EasyCopy/issues/2) 中提供了更简洁的实现方式

0 comments on commit 04c9fa4

Please sign in to comment.