CSDN Guest Copyer (CSDN 匿名复制)

CSDN 匿名免登录,一键复制!

  1. // ==UserScript==
  2. // @name CSDN Guest Copyer (CSDN 匿名复制)
  3. // @version 1.0.0
  4. // @description CSDN 匿名免登录,一键复制!
  5. // @author Zhifeng Hu
  6. // @icon https://img-home.csdnimg.cn/images/20201124032511.png
  7. // @match https://blog.csdn.net/*/article/details/*
  8. // @require https://libs.baidu.com/jquery/1.9.1/jquery.min.js
  9. // @grant GM_addStyle
  10. // @grant GM_setClipboard
  11. // @namespace https://github.com/huzhifeng/
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. console.log('CSDN Guest Copyer');
  19.  
  20. //去除登录框
  21. GM_addStyle(".login-mark,#passportbox{display:none!important;}");
  22.  
  23. //一键复制
  24. $(".hljs-button").attr("data-title", "一键复制");
  25. $(".hljs-button").click(function(){
  26. GM_setClipboard(this.parentNode.innerText);
  27. $(".hljs-button").attr("data-title", "复制成功");
  28. setTimeout(function(){
  29. $(".hljs-button").attr("data-title", "一键复制");
  30. }, 1000);
  31. });
  32.  
  33. //获取代码块
  34. let codes = document.querySelectorAll("code");
  35. codes.forEach(c =>{
  36. c.contentEditable = "true";
  37. });
  38. })();