Greasy Fork镜像 支持简体中文。

Restore Clipboard ( 剪贴板消毒,去掉版权信息 )

remove annoying copyright words on zhihu.com, jianshu.com, douban.com...

  1. // ==UserScript==
  2. // @name Restore Clipboard ( 剪贴板消毒,去掉版权信息 )
  3. // @namespace https://github.com/harryhare
  4. // @version 0.4.11
  5. // @description remove annoying copyright words on zhihu.com, jianshu.com, douban.com...
  6. // @author harryhare
  7. // @license GPL 3.0
  8. // @icon https://raw.githubusercontent.com/harryhare/userscript/master/index.png
  9. // @match https://*.zhihu.com/**
  10. // @match https://*.jianshu.com/**
  11. // @match https://*.douban.com/**
  12. // @match https://*.csdn.net/**
  13. // @match https://*.ftchinese.com/**
  14. // @match https://*.1point3acres.com/**
  15. // @match https://blog.skk.moe/**
  16. // @match https://www.bilibili.com/**
  17. // @match https://juejin.cn/**
  18. // @match https://*.nowcoder.com/**
  19. // @match https://*.mbalib.com/**
  20. // @match http://www.360doc.com/**
  21. // @match https://www.360doc.com/**
  22. // @match https://*.geekbang.org/**
  23. // @grant none
  24. // ==/UserScript==
  25.  
  26. // use match instead of include
  27. // https://stackoverflow.com/questions/31817758/what-is-the-difference-between-include-and-match-in-userscripts
  28.  
  29. // 代码思路
  30. // if ( oncopy 所在的 element 在 document 上){
  31. // 在 document.body 上 stopPropagation();
  32. // }
  33. // else if level( oncopy 所在的 element) > level(content element){
  34. // 在 content element 上调用 stopPropagation();
  35. // }
  36. // else if level( oncopy 所在的 element) == level(content element){
  37. // 操作剪贴板
  38. // }
  39.  
  40.  
  41. function rewrite_html(e){
  42. let inner=e.innerHTML;
  43. e.innerHTML=inner;
  44. }
  45.  
  46. function do_douban(){
  47. var targets=document.querySelectorAll('div#link-report .note,div.review-content.clearfix');
  48. for(let i=0;i<targets.length;i++){
  49. targets[i].oncopy=(e)=>{e.stopPropagation();};
  50. }
  51. }
  52.  
  53. function do_csdn(){
  54. var targets=document.querySelectorAll('div#article_content');
  55. for(let i=0;i<targets.length;i++){
  56. targets[i].oncopy=(e)=>{e.stopPropagation();};
  57. }
  58. }
  59.  
  60. function do_juejin(){
  61. var targets=document.querySelectorAll('div.article-content div.markdown-body');
  62. for(let i=0;i<targets.length;i++){
  63. targets[i].oncopy=(e)=>{e.stopPropagation();};
  64. }
  65. }
  66.  
  67. function do_360doc(){
  68. var targets=document.querySelectorAll('div.doc360article_content');
  69. for(let i=0;i<targets.length;i++){
  70. targets[i].oncopy=(e)=>{e.stopPropagation();};
  71. }
  72. }
  73.  
  74. function do_bilibili(){
  75. var targets=document.querySelectorAll('div#read-article-holder');
  76. for(let i=0;i<targets.length;i++){
  77. targets[i].oncopy=(e)=>{e.stopPropagation();};
  78. }
  79. }
  80.  
  81. function do_zhihu(){
  82. //var targets=document.querySelectorAll('div.RichContent--unescapable');# 使用这个selecter,后面动态加载的部分依然会有问题
  83. var targets=document.querySelectorAll('main.App-main');
  84. for(let i=0;i<targets.length;i++){
  85. targets[i].oncopy=(e)=>{e.stopPropagation();};
  86. //targets[i].className=""
  87. }
  88. }
  89.  
  90.  
  91.  
  92. // B站改了,这个是原先的代码
  93. // function do_bilibili(){
  94. //
  95. // async function clean(e) {
  96. // e.preventDefault();
  97. // //可能有用
  98. // e.stopImmediatePropagation();
  99. // // 在执行完当前事件处理程序之后,停止当前节点以及所有后续节点的事件处理程序的运行
  100. // var copytext = window.getSelection().toString();
  101. // //console.log(await navigator.clipboard.readText());
  102. // await navigator.clipboard.writeText(window.getSelection().toString());
  103. //
  104. //
  105. // // 没有效果
  106. // // var clipdata = e.clipboardData || window.clipboardData;
  107. // // console.log(clipdata.getData('Text'));
  108. // // console.log(clipdata.getData('text/plain'));
  109. // // let clipboardItems = [];
  110. // // console.log("items begin");
  111. // // for (const item of e.clipboardData.items) {
  112. // // console.log(item);
  113. // // if (!item.type.startsWith('image/')) {
  114. // // continue;
  115. // // }
  116. // // clipboardItems.push(
  117. // // new ClipboardItem({
  118. // // [item.type]: item,
  119. // // })
  120. // // );
  121. // // }
  122. // // if (clipdata) {
  123. // // clipdata.setData('text/plain', copytext);
  124. // // clipdata.setData('Text', copytext);
  125. // // }
  126. // }
  127. // var targets=document.querySelectorAll('div.article-holder');
  128. // for(let i=0;i<targets.length;i++){
  129. // targets[i].oncopy=clean;
  130. // }
  131. //
  132. // // 因为B站js函数中有这样的代码,
  133. // // i.preventDefault(),
  134. // // i.stopPropagation()
  135. // // 所以直接在body上面家 listener 没有效果
  136. // // document.body.addEventListener('copy', clean);
  137. // // document.body.oncopy=clean;
  138. // }
  139.  
  140.  
  141. function do_geekbang(){
  142. var last_selection;
  143. var last_selection_string;
  144. var last_selection_range=[];
  145. var last_change_is_copy=false;
  146. document.onselectionchange=(e)=>{
  147. //console.log("on selection changed");
  148. if(last_change_is_copy==true){
  149. //console.log("the fake change!")
  150. last_change_is_copy=false;
  151. return;
  152. }
  153. last_selection=window.getSelection();
  154. // 这句报错不知道怎么做申拷贝
  155. //last_selection=Object.assign({},window.getSelection());
  156. //console.log(last_selection.toString());
  157. last_selection_string=""+last_selection.toString();
  158. last_selection_range=[];
  159. for(var i=0;i<last_selection.rangeCount;i++){
  160. last_selection_range.push(last_selection.getRangeAt(i));
  161. }
  162.  
  163. }
  164.  
  165. async function clean(e) {
  166. // 由于 增加版权声明的代码中有这样的代码
  167. // var e = window.getSelection(),
  168. // e.selectAllChildren(s),
  169. // 这里这句为了防止错误的保存这次变化
  170. last_change_is_copy=true;
  171.  
  172. // window.getSelection() 要用copy,深拷贝才行
  173. //console.log(last_selection==window.getSelection());
  174.  
  175. //此方法可以缓解问题,但是会导致只能复制到单个element 的内容
  176. //window.getSelection().selectAllChildren(e.target);
  177.  
  178. var currnent_selection=window.getSelection();
  179. currnent_selection.removeAllRanges();
  180. for(var i=0;i<last_selection_range.length;i++){
  181. currnent_selection.addRange(last_selection_range[0]);
  182. }
  183. // range 和 直接改clipboard 二选一, clipboard 的结果可以覆盖 window.getSelection() 的状态
  184. //console.log("last_selection string");
  185. //console.log(last_selection_string);
  186. //await navigator.clipboard.writeText(last_selection_string);
  187. //await navigator.clipboard.writeText("测试");
  188. }
  189. document.body.oncopy=clean;
  190. /*
  191. // 由于网站 js 中没有加
  192. // i.stopPropagation()
  193. // 所以不用在同一层,只要在上层(body)处理就可以了
  194. function callback(records){
  195. records.map(function (record) {
  196. if (record.addedNodes.length != 0) {
  197. for(var i=0;i<record.addedNodes.length;i++){
  198. var node=record.addedNodes[i];
  199. if(node.className=="quiz-box"){
  200. var targets=node.querySelectorAll("div#article-content.richcontent");
  201. console.log(targets);
  202. for(let i=0;i<targets.length;i++){
  203. targets[i].oncopy=clean;
  204. }
  205. }
  206. }
  207. }
  208. });
  209. }
  210.  
  211.  
  212.  
  213. var mo = new MutationObserver(callback);
  214.  
  215. var option = {
  216. 'childList': true,
  217. 'subtree': true,
  218. };
  219.  
  220. mo.observe(document.body, option);
  221. */
  222. }
  223.  
  224.  
  225. (function() {
  226. 'use strict';
  227. if(location.href.match("https://[a-z]+.douban.com")!=null){
  228. do_douban();
  229. }else if(location.href.match("https://[a-z]+.csdn.net")!=null){
  230. do_csdn();
  231. }else if(location.href.match("https://[a-z]+.bilibili.com")!=null){
  232. do_bilibili();
  233. }else if(location.href.match("https://juejin.cn")!=null){
  234. do_juejin();
  235. }else if(location.href.match("https?://www.360doc.com")!=null){
  236. do_360doc();
  237. }else if(location.href.match("https://[a-z]+.geekbang.org")!=null){
  238. do_geekbang();
  239. }else if(location.href.match("https://[a-z]+.zhihu.com")!=null){
  240. do_zhihu();
  241. }else{
  242. document.body.oncopy=(e)=>{e.stopPropagation();};
  243. //document.documentElement.addEventListener('copy',function(e){e.stopImmediatePropagation()});
  244. //document.documentElement.addEventListener('copy',function(e){e.stopPropagation()});
  245. //document.body.addEventListener('copy',function(e){e.stopPropagation()});
  246. //document.body.oncopy=function(e){e.stopPropagation()};
  247. }
  248.  
  249.  
  250. /*
  251. var targets=document.querySelectorAll('span.RichText.CopyrightRichText-richText');
  252. for(let i=0;i<targets.length;i++){
  253. //rewrite_html(targets[i].parentElement);
  254. targets[i].oncopy=(e)=>{e.stopPropagation();};
  255. targets[i].parentElement.oncopy=(e)=>{e.stopPropagation();};
  256. targets[i].parentElement.parentElement.oncopy=(e)=>{e.stopPropagation();};
  257. }*/
  258. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址