HappyCSDN

做一个快乐的CV工程师,连接直接跳转,移除复制小尾巴,移除下载推荐

目前为 2023-02-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name HappyCSDN
  3. // @namespace http://tampermonkey.net/
  4. // @homepage https://github.com/mouday/tampermonkey-script
  5. // @version 0.3
  6. // @description 做一个快乐的CV工程师,连接直接跳转,移除复制小尾巴,移除下载推荐
  7. // @author Mouday
  8. // @email pengshiyuyx@163.com
  9. // @icon https://csdnimg.cn/public/favicon.ico
  10.  
  11. // @match *://blog.csdn.net/*/article/details/*
  12. // @match *://*.blog.csdn.net/article/details/*
  13.  
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. // 新tab打开文章内部链接,取消中间跳转,加快coding步伐
  18. function openLinkOnNewTab(){
  19. for(let a of [...document.querySelectorAll('#article_content a')]){
  20. a.target = '_blank';
  21. a.addEventListener('click', (e) => {
  22. e.stopPropagation()
  23. });
  24. }
  25. }
  26.  
  27. // 移除复制小尾巴,保护delete键
  28. function removeCopyAppend(){
  29. document.querySelector('#article_content').addEventListener('copy', function(e){
  30. e.stopPropagation()
  31. })
  32. }
  33.  
  34.  
  35. // 移除下载推荐栏,避免点错浪费时间
  36. function removeDownloadRecommendBox(){
  37. document.querySelector('.second-recommend-box').style.display = 'none';
  38. document.querySelector('.first-recommend-box').style.display = 'none';
  39.  
  40. }
  41.  
  42. // 自动展开代码 2023-02-16
  43. function autoExpandCode(){
  44. document.querySelectorAll('.hide-preCode-bt').forEach(item=>item.click())
  45. }
  46.  
  47. (function() {
  48. 'use strict';
  49. openLinkOnNewTab();
  50. removeCopyAppend();
  51. removeDownloadRecommendBox();
  52. autoExpandCode();
  53. })();