-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathcsdn-blocker.user.js
66 lines (58 loc) · 2.79 KB
/
csdn-blocker.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name 解除CSDN登录复制
// @namespace https://github.com/ChinaGodMan/UserScripts
// @version 1.0.0.23
// @name:zh-CN 解除CSDN登录复制
// @description:zh-CN 去你妈的CSDN登录复制,无需登录即可复制
// @description 去你妈的CSDN登录复制,无需登录即可复制
// @author 人民的勤务员 <[email protected]>
// @match https://blog.csdn.net/*
// @supportURL https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL https://github.com/ChinaGodMan/UserScripts
// @grant none
// @license MIT
// @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI+PHBhdGggZD0iTTEzLDlIMTguNUwxMywzLjVWOU02LDJIMTRMMjAsOFYyMEEyLDIgMCAwLDEgMTgsMjJINkM0Ljg5LDIyIDQsMjEuMSA0LDIwVjRDNCwyLjg5IDQuODksMiA2LDJNMTAuNSwxMUM4LDExIDYsMTMgNiwxNS41QzYsMTggOCwyMCAxMC41LDIwQzEzLDIwIDE1LDE4IDE1LDE1LjVDMTUsMTMgMTMsMTEgMTAuNSwxMU0xMC41LDEyLjVBMywzIDAgMCwxIDEzLjUsMTUuNUMxMy41LDE2LjA2IDEzLjM1LDE2LjU4IDEzLjA4LDE3TDksMTIuOTJDOS40MiwxMi42NSA5Ljk0LDEyLjUgMTAuNSwxMi41TTcuNSwxNS41QzcuNSwxNC45NCA3LjY1LDE0LjQyIDcuOTIsMTRMMTIsMTguMDhDMTEuNTgsMTguMzUgMTEuMDYsMTguNSAxMC41LDE4LjVBMywzIDAgMCwxIDcuNSwxNS41WiIgZmlsbD0iI2NjMDAwMCIgLz48L3N2Zz4=
// ==/UserScript==
(function () {
'use strict'
function timeoutAfterLoad(callback, delay) {
setTimeout(callback, delay)
}
timeoutAfterLoad(() => {
// 修改复制按钮
document.querySelectorAll('.hljs-button').forEach((e) => {
e.setAttribute('data-title', '点击复制')
e.classList.remove('signin')
e.removeAttribute('onclick')
e.addEventListener('click', () => {
e.setAttribute('data-title', ' ')
navigator.clipboard.writeText(e.parentNode.innerText)
e.setAttribute('data-title', '复制成功')
setTimeout(() => e.setAttribute('data-title', '点击复制'), 1200)
})
})
// 复制功能
document.querySelector('.blog-content-box').addEventListener(
'copy',
(e) => {
e.stopPropagation()
e.preventDefault()
navigator.clipboard.writeText(window.getSelection().toString())
},
true
)
document.addEventListener(
'keydown',
(e) => {
if (e.ctrlKey && e.keyCode == 67) { // Ctrl+C
e.stopPropagation()
e.preventDefault()
navigator.clipboard.writeText(window.getSelection().toString())
}
},
true
)
document.oncopy = null
window.oncopy = null
}, 500)
})()