Greasy Fork is available in English.
保留原结构的情况下去除 掘金、知乎的版权限制,移除掘金的外链确认
当前为
// ==UserScript==
// @name 净化剪切板
// @namespace
// @version 0.3.1
// @description 保留原结构的情况下去除 掘金、知乎的版权限制,移除掘金的外链确认
// @author renmu
// @match *://*.juejin.cn/*
// @match *://*.zhihu.com/*
// @grant none
// ==/UserScript==
function getSelectionHtml() {
var html = "";
if (typeof window.getSelection != "undefined") {
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
container.appendChild(sel.getRangeAt(i).cloneContents());
}
html = container.innerHTML;
}
} else if (typeof document.selection != "undefined") {
if (document.selection.type == "Text") {
html = document.selection.createRange().htmlText;
}
}
return html;
}
function addLink(e) {
e.preventDefault();
var copytext = getSelectionHtml();
var clipboardData = event.clipboardData || window.clipboardData;
clipboardData.setData("text/html", copytext);
clipboardData.setData("text", window.getSelection());
}
// 移除掘金的跳转链接
function antiExtraA(){
for (let item of document.getElementsByClassName("article-content")[0].getElementsByTagName("a")) {
item.href = item.title
}
}
document.addEventListener("copy", addLink);
window.onload = function(){
antiExtraA()
}