├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ └── ISSUE_TEMPLATE.md ├── LICENSE ├── README.md ├── csdngreener_greasyfork.user.js └── csdngreener_openuserjs.user.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://doc.stackoverflow.wiki/web/#/21?page_id=138'] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 问题反馈 3 | about: 遇到了问题或有意见? 4 | title: '' 5 | labels: help wanted 6 | assignees: adlered 7 | 8 | --- 9 | 10 | > 加入 QQ 群 1042370453 可直接与作者沟通 11 | 12 | ### 请描述你遇到的问题: 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Adlered 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 |
15 | CSDNGreener,一款专为 Tampermonkey 插件打造的 CSDN 绿化脚本。 16 |

17 | 18 | ### :iphone: 兼容性 19 | 20 | CSDNGreener 是一个优化 CSDN 广告、使用体验的脚本,有口皆碑。 21 | 在使用脚本之前,你需要为浏览器安装脚本管理器插件。 22 | 经过测试,我们确定兼容以下浏览器和插件用于安装此脚本。 23 | 24 | #### :globe_with_meridians: 浏览器支持(任选其一即可) 25 | 26 | * Chrome 或 基于 Chromium 内核的浏览器 (Edge、360浏览器、CentBrowser等) *推荐 27 | * Firefox *功能兼容,但并非最佳性能 28 | 29 | #### :see_no_evil: 浏览器需要安装的脚本管理器插件(任选其一即可) 30 | 31 | * Tampermonkey (新油猴) *插件安装链接 32 | * Violentmonkey (暴力猴) *插件安装链接 33 | 注:Greasemonkey (旧油猴) 由于过于古老,无法支援该脚本。 34 | 35 | #### :test_tube: 支持的操作系统 36 | 37 | * Windows、MacOS、Linux 等支持 Chrome 或 Firefox 浏览器的所有操作系统 *移动平台如 iOS、Android 除外 38 | 39 | ### :page_facing_up: 安装脚本 40 | 41 | * 从 GreasyFork 安装 42 | 通过 GreasyFork 安装脚本: **[点我](https://greasyfork.org/zh-CN/scripts/378351)** 43 | * 从 OpenUserJS 安装 44 | 通过 OpenUserJS 安装脚本: **[点我](https://openuserjs.org/scripts/AdlerED/%E6%9C%80%E5%BC%BA%E7%9A%84%E8%80%81%E7%89%8C%E8%84%9A%E6%9C%ACCSDNGreener%EF%BC%9ACSDN%E5%B9%BF%E5%91%8A%E5%AE%8C%E5%85%A8%E8%BF%87%E6%BB%A4%E3%80%81%E4%BA%BA%E6%80%A7%E5%8C%96%E8%84%9A%E6%9C%AC%E4%BC%98%E5%8C%96)** 45 | 然后点击页面右上角的`Install`进行安装. 46 | * 从 ScriptCat 安装 47 | 通过 ScriptCat 安装脚本: **[点我](https://scriptcat.org/script-show-page/534)** 48 | 49 | ### :rocket: 贡献 50 | 欢迎对本项目提交“Issues”帮助我完善脚本; 51 | 如果你对JS有所了解,可以直接提交**Pull Requests**,要求如下: 52 | 53 | 修改三处版本信息: 54 | 55 | * 修改版本号 56 | 57 | ##### 如果第三位<10,将第三位+1,如果第三位=10,将第二位+1,第三位=0 58 | ##### 例:1.1.9 => 1.2.0 ;; 1.1.3 => 1.1.4 59 | ``` 60 | // @version 1.1.9 61 | ``` 62 | 63 | * 修改版本号(要求同上) 64 | 65 | ``` 66 | var version = "1.1.9"; 67 | ``` 68 | 69 | * 将更新描述在最上方加上一行,修改版本号(要求同上),并修改更新描述: 70 | 71 | ``` 72 | // @note 19-06-04 1.1.9 (更新描述) 73 | ``` 74 | 75 | ### :heart: [捐助](https://doc.stackoverflow.wiki/web/#/21?page_id=138)特别鸣谢 76 | 77 | | 捐助者 | 渠道 | 时间 | 作者寄语 | 78 | | ------ | ------ | ------ | ------ | 79 | | *\*朋 | 支付宝 | 2020年06月08日 14:52 | 感谢你的匿名捐助! | 80 | | *羽 | 微信 | 2020年06月12日 10:48 | 感谢你的匿名捐助! | 81 | | *阳 | 微信 | 2020年06月12日 10:59 | 感谢你的匿名捐助! | 82 | | *\*霖 | 支付宝 | 2020年06月17日 09:53 | 感谢你的匿名捐助! | 83 | | *\*辉 | 支付宝 | 2020年06月19日 14:44 | 感谢你的匿名捐助! | 84 | | *洋 | 支付宝 | 2020年06月19日 23:10 | 感谢你的匿名捐助! | 85 | | R*N | 微信 | 2020年06月23日 15:32 | 感谢你的匿名捐助! | 86 | | [涛之雨](https://greasyfork.org/zh-CN/users/447976-%E6%B6%9B%E4%B9%8B%E9%9B%A8) | QQ 钱包 | 2020年06月26日 23:03 | 感谢老铁的友情赞助! | 87 | -------------------------------------------------------------------------------- /csdngreener_greasyfork.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 「CSDNGreener」🍃CSDN广告完全过滤|免登录|个性化排版|最强老牌脚本|持续更新 3 | // @namespace https://github.com/adlered 4 | // @version 4.2.4 5 | // @description ⚡️全新4.0版本!拥有数项独家功能的最强CSDN脚本,不服比一比⚡️|🕶无需登录CSDN,获得比会员更佳的体验|🖥自定义背景图,分辨率自适配,分屏不用滚动|💾超级预优化|🏷原创文章免登录展开|🔌独家推荐内容自由开关|📠免登录复制|🔗防外链重定向|📝独家论坛未登录自动展开文章、评论|🌵全面净化|📈沉浸阅读|🧴净化剪贴板|📕作者信息文章顶部展示 6 | // @author Adler 7 | // @connect www.csdn.net 8 | // @include *://*.csdn.net/* 9 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-cookie/1.4.1/jquery.cookie.min.js 10 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/nprogress/0.2.0/nprogress.min.js 11 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/clipboard.js/2.0.10/clipboard.min.js 12 | // @supportURL https://github.com/adlered/CSDNGreener/issues/new?assignees=adlered&labels=help+wanted&template=ISSUE_TEMPLATE.md&title= 13 | // @contributionURL https://doc.stackoverflow.wiki/web/#/21?page_id=138 14 | // @grant GM_addStyle 15 | // @grant GM_setValue 16 | // @grant GM_getValue 17 | // @license AGPL-3.0-or-later 18 | // @antifeature ads CSDNGreener 脚本中嵌入了可一键永久关闭的小广告,不会影响您的使用体验:) 请放心安装! 19 | // @note 24-07-18 4.2.4 描述更改 20 | // @note 24-03-28 4.2.3 标题更改 21 | // @note 23-12-21 4.2.2 修复了一些已知问题 22 | // @note 23-12-16 4.2.1 文章页牛皮癣优化 23 | // @note 23-12-15 4.2.0 优化顶栏显示内容,修复了若干由于CSDN前端变化导致优化失效的问题 24 | // @note 23-05-25 4.1.9 再次修复免登录复制无法使用的问题 25 | // @note 23-05-11 4.1.8 强杀变异型登录框弹出(不影响自己点击登录使用) 26 | // @note 23-05-10 4.1.7 增强免登录复制功能 27 | // @note 23-04-11 4.1.6 去广告更新 28 | // @note 23-04-06 4.1.5 新增: 跳过 CSDN 的 link 页面 29 | // @note 23-04-04 4.1.4 增加ads标识 30 | // @note 23-03-30 4.1.3 移除统计代码,登录问题相关优化(只屏蔽一次) 31 | // @note 23-02-03 4.1.2 修复了无法登录的问题(评论不登录无法加载暂无解决方案,我们在持续努力中) 32 | // @note 22-05-30 4.1.1 功能修复,广告屏蔽 33 | // @note 22-01-18 4.1.0 代码折叠适配 34 | // @note 22-01-05 4.0.9 更新广告 35 | // @note 21-12-12 4.0.8 屏蔽学生认证 36 | // @note 21-10-21 4.0.7 屏蔽红包雨 37 | // @note 21-09-24 4.0.6 修复登录弹窗无法彻底去除的问题 38 | // @note 21-09-20 4.0.5 增加自定义背景功能 39 | // @note 21-09-13 4.0.4 增加一个没有收钱的广告(在设置里,不影响体验) 40 | // @note 21-09-01 4.0.3 增加用户使用情况统计模块 41 | // @note 21-08-25 4.0.2 修复右侧置顶栏按钮消失的问题 42 | // @note 21-08-21 4.0.1 去除右侧悬浮栏,优化脚本 43 | // @note 21-08-20 4.0.0 全新4.0发布!UI美化,代码优化,兼容Firefox,更多排版模式 44 | // @note 21-08-20 3.5.7 修复无法完整复制、保存csdn的网页会跳转首页的问题 45 | // @note 21-08-19 3.5.6 自动隐藏底栏功能改为始终隐藏底栏 46 | // @note 21-08-18 3.5.5 修复无法选择复制的问题 47 | // @note 21-06-17 3.5.4 去除右侧红包悬浮窗 48 | // @note 21-04-18 3.5.3 增加显示小店的设定 49 | // @note 21-03-13 3.5.2 去主页广告,去文章页面推荐内容Title 50 | // @note 21-03-01 3.5.1 修改文案 51 | // @note 21-02-06 3.5.0 修复上传资源界面标签选择消失的问题 52 | // @note 21-01-17 3.4.9 删除文章页和论坛广告,暂时停用右侧栏滚动功能(CSDN限制) 53 | // @note 21-01-15 3.4.8 保存按钮优化,修复显示创作中心按钮功能失效的问题 54 | // @note 21-01-15 3.4.7 改进脚本细节,增加广告屏蔽能力,修复绿化按钮错位的问题 55 | // @note 20-12-25 3.4.6 主页部分嵌入式广告删除 56 | // @note 20-12-18 3.4.5 修复绿化设定按钮排版不正确的问题 57 | // @note 20-12-15 3.4.4 修复了某些子页显示不正常的问题 58 | // @note 20-10-23 3.4.3 适应新版CSDN,去除主页和登录页广告,以及登录提示,并移除底部信息 59 | // @note 20-10-20 3.4.2 删除右侧广告 60 | // @note 20-09-26 3.4.1 修改排版设定,修复登录框弹出的问题 61 | // @note 20-09-24 3.4.0 紧急修复由于CSDN前端样式修改导致设定开关丢失的问题 62 | // @note 20-08-27 3.3.9 紧急修复由于CSDN前端样式修改导致脚本失效的问题 63 | // @note 20-08-26 3.3.8 合法脚本提示 64 | // @note 20-07-20 3.3.7 修复菜单栏在创作中心显示异常的问题 65 | // @note 20-07-18 3.3.6 工具箱按钮优化 66 | // @note 20-07-05 3.3.5 评论复制功能交互优化 67 | // @note 20-07-04 3.3.4 修复右侧栏消失的问题 68 | // @note 20-07-03 3.3.3 新增复制评论功能!删除顶部广告 69 | // @note 20-06-28 3.3.2 提示修改 70 | // @note 20-06-27 3.3.1 弹窗提示逻辑修改为仅提示一次。 71 | // @note 20-06-27 3.3.0 网站标题新消息提醒去除 72 | // @note 20-06-26 3.2.9 恢复GreasyFork平台脚本支持 73 | // @note 20-06-21 3.2.0 脚本迁移通知 74 | // @note 20-06-21 3.1.9 增加自动隐藏底栏功能 75 | // @note 20-06-21 3.1.8 增加自动隐藏顶栏功能,修复选项窗口被点赞长条挡住的Bug,选项窗口布局修改 76 | // @note 20-06-20 3.1.7 设置窗口大小固定,增加打赏入口 77 | // @note 20-06-19 3.1.6 显示推荐内容按钮回归,新布局紧急修复 78 | // @note 20-06-18 3.1.5 自定义功能更新 79 | // @note 20-06-16 3.1.4 支持大部分功能模块化显示 80 | // @note 20-06-14 3.1.3 绿化设定优化 81 | // @note 20-06-14 3.1.2 ISSUE模板调整Support URL 82 | // @note 20-06-14 3.1.1 增加搜博主文章模块 83 | // @note 20-06-13 3.1.0 修复设置过期的问题 84 | // @note 20-06-12 3.0.9 标题回滚 85 | // @note 20-06-12 3.0.8 主页广告删除,绿化设置仅显示在文章页面,删除页脚,顶部优化,若干细节优化 86 | // @note 20-06-11 3.0.7 增加官方QQ交流群,增加关闭强制白色主题功能 87 | // @note 20-06-11 3.0.6 用户名片功能优化 88 | // @note 20-06-11 3.0.5 优化加载速度 89 | // @note 20-06-10 3.0.4 修复设置界面遮挡的问题,显示博主头像 90 | // @note 20-06-09 3.0.3 默认设定修改 91 | // @note 20-06-09 3.0.2 修复推荐内容按钮刷新不生效的问题,增加工具箱提示框 92 | // @note 20-06-08 3.0.1 设置中心推出!增加浏览效果选项 && Green Book Icon Update 93 | // @note 20-06-08 3.0.0 设置中心推出!增加浏览效果选项 94 | // @note 20-06-07 2.4.2 设置解耦,下个版本搞配置中心 95 | // @note 20-06-06 2.4.1 修复文章内容消失的问题 96 | // @note 20-06-04 2.4.0 修复推荐按钮错位的问题 97 | // @note 20-06-04 2.3.9 窄屏适配优化 98 | // @note 20-06-04 2.3.8 黑夜模式出现问题,紧急回档到 2.3.6 99 | // @note 20-06-03 2.3.7 感谢 @AlexLWT 增加黑暗模式 100 | // @note 20-06-02 2.3.6 AdsByGoogle 删除 101 | // @note 20-05-25 2.3.5 感谢 @RyanIPO 修复 Cannot read property 'replace' of undefined 报错的问题 102 | // @note 20-05-24 2.3.4 修复免登录复制功能 103 | // @note 20-05-22 2.3.3 Logo与背景同步 104 | // @note 20-05-22 2.3.2 深度删除背景 105 | // @note 20-05-20 2.3.1 通过require使用NProgress 106 | // @note 20-05-20 2.3.0 显示推荐内容按钮样式内置,剔除CDN 107 | // @note 20-05-17 2.2.9 进度条样式更新,时间延时优化 108 | // @note 20-05-17 2.2.8 更新脚本描述,展开评论的所有回复,删除创作中心按钮,加载进度条 109 | // @note 20-05-17 2.2.7 更新脚本描述 110 | // @note 20-05-16 2.2.6 修复第一次点击显示推荐内容无反应的问题 111 | // @note 20-05-16 2.2.5 删除抢沙发角标,修改显示推荐内容按钮样式 112 | // @note 20-05-16 2.2.4 感谢来自GitHub的朋友“HeronZhang”的Issue建议,删除所有博客花里胡哨的背景,主页分类中广告清除,CSS样式控制宽度适配代码优化 113 | // @note 20-05-16 2.2.3 感谢来自GitHub的朋友“RetiredWorld”的代码贡献,使用CSS来控制样式,而不是JS,增大灵活性。 114 | // @note 20-05-13 2.2.2 屏蔽您的缩放不是100%的提示 115 | // @note 20-04-29 2.2.1 感谢大家的支持,增加目录显示,自动判断是否存在目录调整页面宽度,屏蔽新增广告,欢迎大家体验并提出意见! 116 | // @note 20-04-15 2.2.0 一些广告被其他插件屏蔽导致的异常无视之 117 | // @note 20-03-30 2.1.9 干掉“记录你的创作历程”,干掉未登录情况下的角标提醒 118 | // @note 20-03-13 2.1.8 窄屏适配加强 119 | // @note 20-03-13 2.1.7 更新简介 120 | // @note 20-03-12 2.1.6 宽度自适应(感谢来自GitHub的朋友LeonG7的建议)!修复剪贴板净化无效的问题。 121 | // @note 20-03-04 2.1.5 适配AdGuard 122 | // @note 20-02-27 2.1.4 优化免登录复制 123 | // @note 20-02-25 2.1.3 免登录复制更新,现已可用 124 | // @note 20-02-24 2.1.2 By Github@JalinWang 更改去除剪贴板劫持的方式,使得原文格式在复制时能够保留 125 | // @note 20-02-22 2.1.1 紧急修复由于 CSDN 修改前端结构导致的文章错位 126 | // @note 20-02-11 2.1.0 若干动画优化,视觉体验更流畅 127 | // @note 20-02-06 2.0.9 武汉加油!修改推荐内容切换开关位置,减少违和感 128 | // @note 20-01-17 2.0.8 去除右侧广告 129 | // @note 20-01-17 2.0.7 感谢来自GitHub的朋友“gleans”的建议,去掉页头广告 130 | // @note 19-12-12 2.0.6 感谢来自GitHub的朋友“yexuesong”的建议,将作者信息在文章顶部展示 131 | // @note 19-10-30 2.0.5 美化隐藏按钮,增加点击动画 132 | // @note 19-10-30 2.0.4 删除CSDN官方在主页推送的文章(大多是广告) 133 | // @note 19-10-30 2.0.3 添加更多屏蔽脚本 134 | // @note 19-10-30 2.0.0 祝自己生日快乐~完全重写CSDNGreener,统一使用JQuery,效率更高 135 | // @note 19-10-27 1.5.2 删除分享海报提示&&感谢GitHub的朋友“CHN-STUDENT”的反馈,去除底部课程推荐 136 | // @note 19-10-27 1.5.1 感谢来自GitHub的朋友“CHN-STUDENT”的细致复现反馈,去除了底部的课程推荐广告 137 | // @note 19-10-04 1.5.0 移除了底部主题信息和打赏 138 | // @note 19-09-10 1.4.9 感谢来自GitHub的朋友“programmerZe”的细致复现反馈,修复了评论区点击查看回复后,已经展开的评论会收起的问题 139 | // @note 19-09-04 1.4.8 感谢来自GitHub的朋友“dwdcth”的细致复现反馈,现在查看原创文章不会无限弹登录窗口了,且加强了自动展开功能 140 | // @note 19-08-20 1.4.7 感谢油叉用户“SupremeSir”的反馈,修复了右侧悬浮栏遮挡文章的问题 141 | // @note 19-08-14 1.4.6 无语。刚更新的免登录复制,又改了。修复! 142 | // @note 19-08-13 1.4.5 更新了独家功能:免登录复制 143 | // @note 19-08-13 1.4.4 感谢来自GitHub的朋友“iamsunxing”的反馈,修复了顶部不贴边的问题 144 | // @note 19-08-01 1.4.3 感谢油叉用户“ddddy”的反馈,去除了更多推广广告 145 | // @note 19-07-30 1.4.2 感谢油叉用户“周义杰”的反馈,增加了防CSDN外链重定向的功能(CSDN臭流氓) 146 | // @note 19-07-20 1.4.1 修复了推荐内容开关跨文章无效问题(忘了配置Cookie作用域) 147 | // @note 19-07-19 1.4.0 1. 构架大更新 2. 感谢来自GitHub的朋友"lukemin"的反馈,加入了下方推荐内容是否隐藏开关(实用) 148 | // @note 19-07-13 1.3.0 感谢来自GitHub的朋友“Holaplace”的反馈,修复了文章无法自动展开的问题(CSDN总改这个,令人头疼) 149 | // @note 19-06-08 1.2.6 感谢油叉用户“DeskyAki”的反馈,修复了文章无法自动展开的问题 150 | // @note 19-06-07 1.2.4 修复了登录后评论无法正常打开的问题 151 | // @note 19-06-07 1.2.3 感谢油叉用户"永远的殿下"的反馈,在一上午的努力攻克下,终于实现了未登录展开评论的语句 152 | // @note 19-06-05 1.2.0 修复了评论无法自动展开的BUG 153 | // @note 19-06-04 1.1.9 修复了无法自动展开的BUG(自闭了) 154 | // @note 19-06-04 1.1.6 CSDN太坏了,把“消息”按钮的Class设置成了“GitChat”,所以修复了“消息”按钮消失的问题 155 | // @note 19-06-04 1.1.5 1. 优化了论坛体验 2.美化、优化代码结构 156 | // @note 19-06-04 1.1.4 感谢来自GitHub的朋友“iamsunxing”的反馈,增加了论坛广告匹配规则 157 | // @note 19-06-03 1.1.3 感谢来自GitHub的朋友“wangwei135”的反馈,去除了评论区上方的广告 158 | // @note 19-05-27 1.1.2 感谢油叉用户“夏伟杰”的反馈,修复了富文本编辑器无法使用的问题 159 | // @note 19-05-25 1.1.0 1. 修复了主页广告的问题 2. 论坛自动展开 3. 论坛广告消除 160 | // @note 19-05-25 1.0.9 感谢油叉用户“渣渣不准说话”的反馈,修复了收藏按钮消失的问题 161 | // @note 19-03-01 1.0.3 添加页面选择性过滤规则 162 | // @note 19-03-01 1.0.2 增加了净化剪贴板功能 163 | // @note 19-03-01 1.0.1 修复了排版问题, 优化了代码结构 164 | // @note 19-02-26 1.0.0 初版发布 165 | // @downloadURL https://update.greasyfork.org/scripts/378351/%F0%9F%94%A5%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%F0%9F%94%A5%20CSDN%E5%B9%BF%E5%91%8A%E5%AE%8C%E5%85%A8%E8%BF%87%E6%BB%A4%E3%80%81%E4%BA%BA%E6%80%A7%E5%8C%96%E8%84%9A%E6%9C%AC%E4%BC%98%E5%8C%96%EF%BC%9A%F0%9F%86%95%20%E4%B8%8D%E7%94%A8%E5%86%8D%E7%99%BB%E5%BD%95%E4%BA%86%EF%BC%81%E8%AE%A9%E4%BD%A0%E4%BD%93%E9%AA%8C%E4%BB%A4%E4%BA%BA%E6%83%8A%E5%96%9C%E7%9A%84%E5%B4%AD%E6%96%B0CSDN%E3%80%82.user.js 166 | // @updateURL https://update.greasyfork.org/scripts/378351/%F0%9F%94%A5%E6%8C%81%E7%BB%AD%E6%9B%B4%E6%96%B0%F0%9F%94%A5%20CSDN%E5%B9%BF%E5%91%8A%E5%AE%8C%E5%85%A8%E8%BF%87%E6%BB%A4%E3%80%81%E4%BA%BA%E6%80%A7%E5%8C%96%E8%84%9A%E6%9C%AC%E4%BC%98%E5%8C%96%EF%BC%9A%F0%9F%86%95%20%E4%B8%8D%E7%94%A8%E5%86%8D%E7%99%BB%E5%BD%95%E4%BA%86%EF%BC%81%E8%AE%A9%E4%BD%A0%E4%BD%93%E9%AA%8C%E4%BB%A4%E4%BA%BA%E6%83%8A%E5%96%9C%E7%9A%84%E5%B4%AD%E6%96%B0CSDN%E3%80%82.meta.js 167 | // ==/UserScript== 168 | var version = "4.2.4"; 169 | var currentURL = window.location.href; 170 | if (currentURL.indexOf("?") !== -1) { 171 | currentURL = currentURL.substring(0, currentURL.indexOf("?")); 172 | } 173 | var list; 174 | var windowTop = 0; 175 | var startTimeMilli = Date.now(); 176 | var stopTimeMilli = 0; 177 | // 配置控制类 178 | class Config { 179 | get(key, value) { 180 | var cookie = $.cookie(key); 181 | if (cookie == undefined) { 182 | new Config().set(key, value); 183 | console.debug("Renew key: " + key + " : " + value); 184 | return value; 185 | } 186 | console.debug("Read key: " + key + " : " + cookie); 187 | if (cookie === "true") { return true; } 188 | if (cookie === "false") { return false; } 189 | return cookie; 190 | } 191 | 192 | getS(key, value) { 193 | var cookie = $.cookie(key); 194 | if (cookie == undefined) { 195 | new Config().set(key, value); 196 | console.debug("Renew key: " + key + " : " + value); 197 | return value; 198 | } 199 | console.debug("Read key: " + key + " : " + cookie); 200 | return cookie; 201 | } 202 | 203 | set(setKey, setValue) { 204 | $.cookie(setKey, setValue, { 205 | path: '/', 206 | expires: 365 207 | }); 208 | console.debug("Key set: " + setKey + " : " + setValue); 209 | } 210 | 211 | listenButton(element, listenKey, trueAction, falseAction) { 212 | $(element).click(function () { 213 | let status = new Config().get(listenKey, true); 214 | console.debug("Status: " + status); 215 | if (status === "true" || status) { 216 | console.debug("Key set: " + listenKey + " :: " + false); 217 | new Config().set(listenKey, false); 218 | } else { 219 | console.debug("Key set: " + listenKey + " :: " + true); 220 | new Config().set(listenKey, true); 221 | } 222 | }); 223 | } 224 | 225 | listenButtonAndAction(element, listenKey, trueAction, falseAction) { 226 | $(element).click(function () { 227 | let status = new Config().get(listenKey, true); 228 | console.debug("Status: " + status); 229 | if (status === "true" || status) { 230 | console.debug("Key set: " + listenKey + " :: " + false); 231 | new Config().set(listenKey, false); 232 | falseAction(); 233 | } else { 234 | console.debug("Key set: " + listenKey + " :: " + true); 235 | new Config().set(listenKey, true); 236 | trueAction(); 237 | } 238 | }); 239 | } 240 | } 241 | var config = new Config(); 242 | var progress = 0; 243 | class Progress { 244 | init() { 245 | progress = 0; 246 | NProgress.start(); 247 | $("#greenerProgress").text("绿化中..."); 248 | $(".toolbar-search").hide(); 249 | } 250 | 251 | setProgress(p) { 252 | progress = p; 253 | $("#greenerProgress").text(progress + "%"); 254 | NProgress.set(progress / 100); 255 | console.log(progress + "%"); 256 | } 257 | 258 | incProgress(p) { 259 | progress = progress + p; 260 | progress = progress > 100 ? 100 : progress; 261 | $("#greenerProgress").text(progress + "%"); 262 | NProgress.set(progress / 100); 263 | console.log(progress + "%"); 264 | } 265 | 266 | done() { 267 | progress = 100; 268 | NProgress.done(); 269 | $("#greenerProgress").html(protect_svg + ' CSDNGreener 正在守护您的浏览体验'); 270 | setTimeout(function() { 271 | $("#greenerProgress").fadeOut(500); 272 | setTimeout(function() { 273 | $(".toolbar-search").fadeIn(500); 274 | if (!isFirefox()) { 275 | // 提示 276 | let tipsCookie = config.get("showTip", true); 277 | if (tipsCookie) { 278 | showTips(); 279 | } 280 | config.set("showTip", false); 281 | } 282 | }, 500); 283 | }, 1500); 284 | } 285 | } 286 | var progressor = new Progress(); 287 | 288 | // 自定义 CSS 289 | // 进度条 290 | $('head').append(""); 291 | // 设置窗口 292 | $('head').append(""); 293 | // 提示条 294 | $('head').append(""); 295 | // 按钮(旧) 296 | $('head').append(""); 297 | // 保存按钮 298 | $('head').append(""); 299 | // Star 样式 300 | $('head').append(""); 301 | // 设置窗口文字效果 302 | if (isFirefox()) { 303 | $('head').append(""); 304 | } else { 305 | $('head').append(""); 306 | } 307 | // SVG 308 | //var save_svg = ''; 309 | var star_svg_1 = ''; 310 | var star_svg_2 = ' '; 311 | var star_svg_3 = ' '; 312 | var star_svg_4 = ' '; 313 | var star_svg = star_svg_1 + star_svg_2 + star_svg_3 + star_svg_4; 314 | var donate_svg = ''; 315 | var set_svg = ''; 316 | var save_svg = ''; 317 | var settings_svg = ''; 318 | var protect_svg = ''; 319 | 320 | // jquery.showtips.js 321 | (function(jQuery) { 322 | jQuery.fn.showTips = function(options,elem){ 323 | var config = { 324 | skin:"trips", 325 | content:$(this).attr("tips")||"弹出类型的气泡提示!", //气泡提示内容里面可以是HTML,默认显示自定义的提示内容 326 | width:"auto", //默认为auto,可以写具体尺寸如:200 327 | alignTo:["right","center"], //箭头方向 328 | color:["rgb(247, 206, 57)","#FFFEF4"], //这里是提示层的风格,第一个参数为提示边框颜色,第二个参数为提示背景颜色 329 | type:"html", //显示内容类型 330 | trigger:"click", //默认为点击显示,show为初始化就显示,hover为经过显示,focus焦点显示,mouse跟随鼠标显示隐藏 331 | spacing:10, //默认为箭头距离对象的尺寸 332 | customid:"", //自定义ID 333 | isclose:false, //是否显示关闭按钮 334 | success : null //成功后的回调函数 335 | }; 336 | var opts = jQuery.extend(config, options); 337 | return this.each(function(){ 338 | var that = jQuery(this),tipBox,tipId,selfH,selfW,conId,docW, spa = opts.spacing, skin=opts.skin; 339 | var Mathrandom = Math.floor(Math.random() * 9999999); 340 | var pmr = (opts.customid=="") ? Mathrandom :opts.customid.replace(/[#.]/, ""); 341 | var pointer=opts.alignTo.length===1 ? ''+opts.alignTo[0]+'' : ''+opts.alignTo[0]+'-'+opts.alignTo[1]+''; 342 | 343 | if(typeof elem == 'string') { 344 | if(elem =="show"){ 345 | jQuery('#tip'+pmr).show(); jQuery("#con"+pmr).html(opts.content); 346 | showPosition(pointer,jQuery('#tip'+pmr)); 347 | }; 348 | if(elem =="hide"){jQuery('#tip'+pmr).hide()}; 349 | }; 350 | if(typeof elem == '' || typeof elem == undefined){return true}; 351 | if(jQuery('#tip'+pmr).length==1){return false;} 352 | tipBox=jQuery('
').appendTo(document.body); 353 | tipId = jQuery("#tip"+pmr); 354 | conId = jQuery("#con"+pmr); 355 | 356 | var edgecolor='border-'+opts.alignTo[0]+'-color', tfi=tipId.find("i"), tfem=tipId.find("em"), tfiem=tipId.find("i,em"); 357 | tipId.css({'position':'absolute',border:'1px solid','border-color':opts.color[0],'background-color':opts.color[1]}); 358 | if(opts.alignTo[1]=='center'){ var offpos=50,percen="%"; }else{ var offpos=5,percen="px"; }; 359 | tfiem.css({width:0,height:0,content:'','position':'absolute'}) 360 | tfi.css({border:'8px solid transparent','z-index':5}); 361 | tfem.css({border:'7px solid transparent','z-index':10}); 362 | switch (pointer) { 363 | case 'top-center': 364 | case 'bottom-center': 365 | case 'top-left': 366 | case 'bottom-left': 367 | var poi="left"; 368 | if(pointer=='top-center' || pointer=='bottom-center'){ 369 | tfi.css({"margin-left":"-8px"}); 370 | tfem.css({"margin-left":"-7px"}); 371 | } 372 | break; 373 | case 'left-center': 374 | case 'right-center': 375 | case 'left-top': 376 | case 'right-top': 377 | var poi="top"; 378 | if(pointer=='left-center' || pointer=='right-center'){ 379 | tfi.css({"margin-top":"-8px"}); 380 | tfem.css({"margin-top":"-7px"}); 381 | } 382 | break; 383 | default: 384 | var poi="right"; 385 | break; 386 | }; 387 | 388 | if(pointer=='follow'){ 389 | tfi.css({'border-bottom-color':opts.color[0],left:''+offpos+percen+'',bottom:'100%'}); 390 | tfem.css({'border-bottom-color':opts.color[1],left:''+(offpos+(opts.alignTo[1]=='center'?0:1))+percen+'',bottom:'100%'}); 391 | }else{ 392 | tfi.css(edgecolor,opts.color[0]).css(poi,''+offpos+percen+''); 393 | tfem.css(edgecolor,opts.color[1]).css(poi,''+(offpos+(opts.alignTo[1]=='center'?0:1))+percen+''); 394 | tfiem.css(opts.alignTo[0],'100%'); 395 | }; 396 | 397 | switch (opts.type) { 398 | case 'html':conId.html(opts.content); break; 399 | case 'id' : 400 | var tempid=jQuery(opts.content) ,wrap = document.createElement("div"); 401 | if(tempid.css("display") == "none"){ tempid.css({display:"block"}); } 402 | conId.append(tempid); 403 | break; 404 | }; 405 | if(opts.isclose){ 406 | jQuery('×').appendTo(tipId); 407 | tipId.find("#close"+pmr+"").on("click",function(){tipId.hide();}); 408 | } 409 | 410 | if(typeof opts.width === 'string'){ 411 | docW = parseInt(document.body.clientWidth*(opts.width.replace('%','')/100)); 412 | (typeof opts.width == 'auto' || typeof opts.width == '') ? tipBox.css({width:'auto'}) : tipBox.css({width:docW}); 413 | tipBox.height(); 414 | }else{ 415 | tipBox.width(opts.width).height(); 416 | } 417 | function showPosition(pointer,cell){ 418 | var selfH = that.outerHeight(true), selfW = that.outerWidth(true); 419 | var post=that.offset().top, posl=that.offset().left; 420 | var tipCell=(cell=="" || cell==undefined) ? tipId : cell; 421 | var tipH=tipCell.outerHeight(true), tipW=tipCell.outerWidth(true); 422 | 423 | switch (pointer) { 424 | case 'top-left': tipCell.css({top:post-tipH-spa,left:posl}); break; 425 | case 'top-center': tipCell.css({top:post-tipH-spa,left:posl-(tipW/2)+(selfW/2)}); break; 426 | case 'top-right': tipCell.css({top:post-tipH-spa,left:posl-(tipW-selfW)}); break; 427 | case 'bottom-left': tipCell.css({top:post+selfH+spa,left:posl}); break; 428 | case 'bottom-center': tipCell.css({top:post+selfH+spa,left:posl-(tipW/2)+(selfW/2)}); break; 429 | case 'bottom-right': tipCell.css({top:post+selfH+spa,left:posl-(tipW-selfW)}); break; 430 | case 'left-top': tipCell.css({top:post,left:posl-tipW-spa}); break; 431 | case 'left-center': tipCell.css({top:post-(tipH/2)+(selfH/2),left:posl-tipW-spa}); break; 432 | case 'right-top': tipCell.css({top:post,left:posl+selfW+spa}); break; 433 | case 'right-center': tipCell.css({top:post-(tipH/2)+(selfH/2),left:posl+selfW+spa}); break; 434 | case 'follow': that.mousemove(function(e) { tipCell.css({top:e.pageY + 30,left:e.pageX - 6}); }); break; 435 | }; 436 | } 437 | tipBox.hide(); 438 | switch (opts.trigger){ 439 | case 'show':showPosition(pointer);tipBox.show();break; 440 | case 'click':that.click(function(){showPosition(pointer);tipBox.show();});break; 441 | case 'hover':that.hover(function(){showPosition(pointer);tipBox.show(); tipBox.on("mouseover",function(){jQuery(this).show()}).on("mouseout",function(){jQuery(this).hide()})},function(){tipBox.hide();});break; 442 | case 'focus':that.focus(function(){showPosition(pointer);tipBox.show();}); that.blur(function(){tipBox.hide();});break; 443 | case 'mouse':that.hover(function(){showPosition(pointer);tipBox.show();},function(){tipBox.hide();});break; 444 | }; 445 | setTimeout(function(){opts.success && opts.success();}, 1); 446 | }); 447 | } 448 | })(jQuery); 449 | 450 | (function () { 451 | 'use strict'; 452 | 453 | l("CSDNGreener V" + version); 454 | if (isFirefox()) { 455 | console.log("您正在使用火狐浏览器,将使用兼容模式运行 CSDNGreener。"); 456 | } 457 | progressor.init(); 458 | 459 | // 绿化设定按钮点击事件 460 | let jss = ""; 461 | jss += ""; 468 | $("body").append(jss); 469 | 470 | // 保存按钮点击事件 471 | let saveJss = ""; 472 | saveJss += ""; 476 | $("body").append(saveJss); 477 | 478 | setTimeout(function() { 479 | var blockURL = currentURL.split("/").length; 480 | var main = /(www\.csdn\.net\/)$/; 481 | var mainNav = /nav/; 482 | var article = /article/; 483 | var bbs = /bbs\.csdn\.net/; 484 | var blog = /blog\.csdn\.net/; 485 | var blog2 = /\/article\/list\//; 486 | var download = /download\.csdn\.net/; 487 | var login = /passport\.csdn\.net/; 488 | var zone = /me\.csdn\.net/; 489 | var other = /(www\.csdn\.net\/)/; 490 | var mp = /mp\.csdn\.net/; 491 | var article_month = /article\/month/; 492 | var link = /link\.csdn\.net/; 493 | var blink = /blink\.csdn\.net/; 494 | 495 | // 数组初始化 496 | list = []; 497 | // 头部分 498 | // APP 499 | // put(".app-app"); 500 | // VIP 501 | put(".vip-caise"); 502 | // 记录你的成长历程(记个毛) 503 | put("#writeGuide"); 504 | // 新通知小圆点(未登录才消掉) 505 | if ($(".userinfo a").text() === '登录/注册') { 506 | put("#msg-circle"); 507 | } 508 | // 顶部谷歌广告 509 | put(".adsbygoogle"); 510 | // 悬浮在顶栏按钮上出现的二维码 511 | put(".appControl"); 512 | // 顶部广告 513 | put(".advert-bg"); 514 | 515 | if (main.test(currentURL) || mainNav.test(currentURL)) { 516 | l("正在优化主页体验..."); 517 | // 常规 518 | // 头部广告 519 | put(".banner-ad-box"); 520 | // 嵌入广告 521 | put("#kp_box_211"); 522 | // 右侧广告 523 | put(".slide-outer"); 524 | // 右侧详情 525 | put(".persion_article"); 526 | // 右侧推荐 527 | $(".feed_company").parent().remove(); 528 | // 广告轮播 529 | put(".el-carousel__container"); 530 | // 顶部横幅 531 | put(".toolbar-advert"); 532 | // 顶栏VIP选项 533 | $('.toolbar-subMenu-box').find("[href='https://mall.csdn.net/vip']").parent().remove(); 534 | // CSDN工具广告 535 | put("#floor-ad_64"); 536 | clean(10); 537 | // common(5, 10); 538 | // 博客及主页优化 539 | common(9, 10); 540 | loop(3); 541 | loop(1); 542 | } else if ((blog.test(currentURL) && blockURL === 4) || blog2.test(currentURL)) { 543 | l("正在优化个人博客主页体验..."); 544 | // 常规 545 | // 头部广告 546 | put(".banner-ad-box"); 547 | // 右侧广告 548 | put(".slide-outer"); 549 | // 右侧详情 550 | put(".persion_article"); 551 | // 左侧广告 552 | put(".mb8"); 553 | put("#kp_box_503"); 554 | put("#kp_box_214"); 555 | clean(10); 556 | // common(5, 10); 557 | loop(3); 558 | loop(1); 559 | } else if (article.test(currentURL) && !mp.test(currentURL) && !article_month.test(currentURL)) { 560 | l("正在优化阅读体验..."); 561 | // 绿化设定 562 | if (isFirefox()) { 563 | setTimeout(function() { 564 | $(".toolbar-container-middle").prepend("
"); 565 | let htmlOf0 = '
' + settings_svg + '
'; 566 | $(".toolbar-btns").prepend(htmlOf0); 567 | if (isFirefox()) { 568 | // 提示 569 | let tipsCookie = config.get("showTip", true); 570 | if (tipsCookie) { 571 | showTips(); 572 | } 573 | config.set("showTip", false); 574 | } 575 | }, 3000); 576 | } else { 577 | $(".toolbar-container-middle").prepend("
"); 578 | let htmlOf0 = '
' + settings_svg + '
'; 579 | $(".toolbar-btns").prepend(htmlOf0); 580 | } 581 | // 常规 582 | // 右侧广告,放到第一个清除 583 | // put(".recommend-right"); 584 | put("#addAdBox"); 585 | // put(".aside-box.kind_person.d-flex.flex-column"); 586 | put(".recommend-top-adbox"); 587 | // put(".recommend-list-box.d-flex.flex-column.aside-box"); 588 | // 左侧广告 589 | // put("#container"); 590 | // 快来写博客吧 591 | put(".blog_tip_box"); 592 | // 推荐关注用户 593 | put(".blog-expert-recommend-box"); 594 | // 右下角VIP 595 | put(".meau-gotop-box"); 596 | // 广告 597 | put(".mediav_ad"); 598 | put(".pulllog-box"); 599 | put(".recommend-ad-box"); 600 | put(".box-shadow"); 601 | put(".type_hot_word"); 602 | put(".fourth_column"); 603 | // 高分辨率时右侧文章推荐 604 | // put(".right-item"); 605 | // 广告 606 | put("#asideFooter"); 607 | put("#ad-div"); 608 | put("#479"); 609 | put("#480"); 610 | // 打赏 611 | put(".postTime"); 612 | // 课程推荐 613 | put(".t0"); 614 | // 分享海报 615 | put(".shareSuggest"); 616 | // 底部主题 617 | put(".template-box"); 618 | // 评论区广告 619 | put("div#dmp_ad_58"); 620 | // 打赏 621 | put(".reward-user-box"); 622 | // 右侧打赏按钮 623 | put(".to-reward"); 624 | // 推荐内容广告 625 | put(".recommend-recommend-box"); 626 | // 右侧广告 627 | put(".indexSuperise"); 628 | // 抢沙发角标 629 | put(".comment-sofa-flag"); 630 | // 页jio 631 | put(".bottom-pub-footer"); 632 | // 登录查看未读消息 633 | put(".toolbar-notice-bubble"); 634 | // 右侧广告 635 | put(".recommend-top-adbox"); 636 | // 右侧四个广告 637 | put(".programmer1Box"); 638 | put(".programmer2Box"); 639 | put(".programmer3Box"); 640 | put(".programmer4Box"); 641 | // 点赞气泡 642 | put(".triplet-prompt"); 643 | // 顶部横幅 644 | put(".toolbar-advert"); 645 | // 底部信息 646 | put(".blog-footer-bottom"); 647 | // 右侧栏广告 648 | put("#6527"); 649 | put("#recommendAdBox"); 650 | // 推荐内容Title 651 | put(".recommend-tit-mod"); 652 | // 红包提醒 653 | put(".csdn-redpack-lottery-btn-box"); 654 | // 学生认证 655 | put(".csdn-highschool-window"); 656 | // 右侧悬浮栏除置顶以外的按钮 657 | put(".option-box[data-type='guide'],.option-box[data-type='cs'],.csdn-common-logo-advert"); 658 | // 登录后您可以享受以下权益 659 | put(".passport-login-tip-container"); 660 | // 底栏“觉得还不错?立即收藏”你在教我做事? 661 | put(".tool-active-list"); 662 | // 文章底部 archive推荐 663 | put("#treeSkill"); 664 | // 搜索框fire emoji 665 | put(".icon-fire"); 666 | clean(10); 667 | setTimeout(function() { 668 | // 展开评论的所有回复 669 | $('.btn-read-reply').click(); 670 | // 右侧toolbar 创作提示 671 | $(".sidetool-writeguide-box").remove(); 672 | }, 1500); 673 | // 主动加入右侧栏 674 | if ($(".recommend-right").length === 0) { 675 | $("#mainBox").after('
'); 676 | } 677 | // 上栏按钮删除 678 | $(".toolbar-menus > li > a:contains('专栏课程')").parent().remove(); 679 | $(".toolbar-menus > li > a:contains('插件')").parent().remove(); 680 | $(".toolbar-menus > li > a:contains('认证')").parent().remove(); 681 | // 修复无法选择复制 682 | $("code").css("user-select","auto"); 683 | $("#content_views").css("user-select","auto"); 684 | $("pre").css("user-select","auto");7 685 | // 图片混文字时,无法完整复制,图片不会被复制下来 https://github.com/adlered/CSDNGreener/issues/87 686 | //let el = $("main .blog-content-box")[0]; 687 | //let elClone = el.cloneNode(true); 688 | //el.parentNode.replaceChild(elClone, el); 689 | // 保存csdn的网页再次打开会自动跳转到首页 https://github.com/adlered/CSDNGreener/issues/97 690 | $("[onerror]").remove(); 691 | // CSDN重定向外链不能在新的窗口跳转 https://github.com/adlered/CSDNGreener/issues/80 692 | $("#article_content a[href]").attr("target", "_blank"); 693 | // 搜索框优化 694 | //$("#toolbar-search-input").css("width", "calc(100% - 400px)"); 695 | // 取消代码折叠 696 | $(".look-more-preCode").click(); 697 | // 询问推荐是否有意义的问卷调查 698 | $("#recommendNps").remove(); 699 | // 绿化设置 700 | common(6, 1); 701 | // 屏幕适配 702 | common(4, 1); 703 | // 评论 704 | common(1, 30); 705 | // 其它 706 | common(2, 20); 707 | // 顶部显示作者信息 708 | common(8, 1); 709 | // 博客及主页优化 710 | common(9, 10); 711 | // 循环线程开始 712 | loop(2); 713 | loop(3); 714 | } else if (bbs.test(currentURL)) { 715 | l("正在优化论坛体验..."); 716 | // 常规 717 | // 评论嵌入小广告 718 | put(".post_recommend"); 719 | // 底部推荐 720 | put("#post_feed_wrap"); 721 | // 底部相关文章里面的广告 722 | put(".bbs_feed_ad_box"); 723 | put(".recommend-ad-box"); 724 | // 底部相关文字里面的热词提示 725 | put(".type_hot_word"); 726 | // 底部蓝色flex属性的广告栏+登录注册框 727 | put(".pulllog-box"); 728 | // 猜你喜欢 729 | put(".personalized-recommend-box"); 730 | // 发帖减半提示 731 | put(".totast-box"); 732 | // 顶部广告 733 | put(".recommend-right"); 734 | // 顶部广告 735 | put(".ad_top"); 736 | // 右侧广告 737 | put(".ad_1"); 738 | clean(10); 739 | // 展开 740 | common(3, 50); 741 | // common(5, 10); 742 | loop(3); 743 | } else if (download.test(currentURL)) { 744 | l("正在优化下载页体验..."); 745 | // 常规 746 | put(".fixed_dl"); 747 | put("indexSuperise"); 748 | // 右侧推荐 749 | put(".content_recom"); 750 | clean(10); 751 | // common(5, 10); 752 | loop(3); 753 | } else if (login.test(currentURL)) { 754 | l("正在优化登录页体验..."); 755 | // 常规 756 | // 登录界面大图广告 757 | put(".main-tu"); 758 | clean(10); 759 | // common(5, 10); 760 | loop(3); 761 | } else if (zone.test(currentURL)) { 762 | l("正在优化个人空间体验..."); 763 | // 常规 764 | clean(10); 765 | common(7, 10); 766 | // common(5, 10); 767 | loop(3); 768 | } else if (blink.test(currentURL)) { 769 | l("正在优化个人动态体验..."); 770 | } else if (link.test(currentURL)) { 771 | // 跳过 CSDN 的 link 页面 772 | var url = new URL(window.location.href) 773 | var target = url.searchParams.get('target') 774 | window.location.href = target 775 | } else { 776 | l("哦豁,好偏门的页面,我来试着优化一下哦..."); 777 | // 常规 778 | // 展开全文 779 | $('.readmore_btn').click(); 780 | // *** index *** 781 | // 头部广告 782 | put(".banner-ad-box"); 783 | // 嵌入广告 784 | put("#kp_box_211"); 785 | // 右侧广告 786 | put(".slide-outer"); 787 | // 右侧详情 788 | put(".persion_article"); 789 | // 右侧推荐 790 | $(".feed_company").parent().remove(); 791 | // *** article *** 792 | // 常规 793 | // 右侧广告,放到第一个清除 794 | put("#addAdBox"); 795 | put(".recommend-top-adbox"); 796 | // 快来写博客吧 797 | put(".blog_tip_box"); 798 | // 推荐关注用户 799 | put(".blog-expert-recommend-box"); 800 | // 右下角VIP 801 | put(".meau-gotop-box"); 802 | // 广告 803 | put(".mediav_ad"); 804 | put(".pulllog-box"); 805 | put(".recommend-ad-box"); 806 | //put(".box-shadow"); 某些页面异常,例如cloud.csdn.net 807 | put(".type_hot_word"); 808 | put(".fourth_column"); 809 | // cloud.csdn.net 头部广告 810 | put("#kp_box_118"); 811 | // 广告 812 | put("#asideFooter"); 813 | put("#ad-div"); 814 | put("#479"); 815 | put("#480"); 816 | // 打赏 817 | put(".postTime"); 818 | // 课程推荐 819 | put(".t0"); 820 | // 分享海报 821 | put(".shareSuggest"); 822 | // 底部主题 823 | put(".template-box"); 824 | // 评论区广告 825 | put("div#dmp_ad_58"); 826 | // 打赏 827 | put(".reward-user-box"); 828 | // 右侧打赏按钮 829 | put(".to-reward"); 830 | // 推荐内容广告 831 | put(".recommend-recommend-box"); 832 | // 右侧广告 833 | put(".indexSuperise"); 834 | // 抢沙发角标 835 | put(".comment-sofa-flag"); 836 | // 页jio 837 | put(".bottom-pub-footer"); 838 | // 登录查看未读消息 839 | put(".toolbar-notice-bubble"); 840 | // 右侧广告 841 | put(".recommend-top-adbox"); 842 | // 学院弹出广告 843 | $(".fouce_close_btn").click(); 844 | // 其它 845 | // 头部广告 846 | put(".banner-ad-box"); 847 | // 右侧广告 848 | put(".slide-outer"); 849 | // 右侧详情 850 | put(".persion_article"); 851 | // 左侧广告 852 | put("#kp_box_503"); 853 | put("#kp_box_214"); 854 | // *** bbs *** 855 | // 评论嵌入小广告 856 | put(".post_recommend"); 857 | // 底部推荐 858 | put("#post_feed_wrap"); 859 | // 底部相关文章里面的广告 860 | put(".bbs_feed_ad_box"); 861 | put(".recommend-ad-box"); 862 | // 底部相关文字里面的热词提示 863 | put(".type_hot_word"); 864 | // 底部蓝色flex属性的广告栏+登录注册框 865 | put(".pulllog-box"); 866 | // 猜你喜欢 867 | put(".personalized-recommend-box"); 868 | // 发帖减半提示 869 | put(".totast-box"); 870 | // 顶部广告 871 | put(".recommend-right"); 872 | // 顶部广告 873 | put(".ad_top"); 874 | // *** download *** 875 | put(".fixed_dl"); 876 | put("indexSuperise"); 877 | // 右侧推荐 878 | put(".content_recom"); 879 | clean(10); 880 | } 881 | setTimeout(function() { 882 | progressor.done(); 883 | }, 0); 884 | stopTimeMilli = Date.now(); 885 | l("优化完毕! 耗时 " + (stopTimeMilli - startTimeMilli) + "ms"); 886 | }, 0); 887 | })(); 888 | 889 | function l(log) { 890 | console.log("[CSDNGreener] " + log); 891 | } 892 | 893 | function e(error) { 894 | console.error("[CSDNGreener] " + error); 895 | } 896 | 897 | function clear() { 898 | list = []; 899 | } 900 | 901 | function put(tag) { 902 | list.push(tag); 903 | } 904 | 905 | function clean(times) { 906 | var loop = setInterval(function () { 907 | --times; 908 | if (times <= 0) { 909 | clearInterval(loop); 910 | } 911 | for (var k = 0; k < list.length; k++) { 912 | $(list[k]).remove(); 913 | } 914 | }, 100); 915 | progressor.incProgress(10); 916 | } 917 | 918 | var deletedLogin = false; 919 | 920 | function loop(num) { 921 | setInterval(function () { 922 | if (num === 1) { 923 | // 主页中间的广告 924 | $(".J_adv").remove(); 925 | // 主页有新的内容横条 926 | $(".feed-fix-box").remove(); 927 | // 主页广告 iframe 928 | if (currentURL == "https://www.csdn.net/") { 929 | $("iframe").remove(); 930 | } 931 | // 删除 CSDN 官方在主页的文章(大多是广告) 932 | $("li.clearfix").each(function(index, ele) { 933 | var banned = /csdn<\/a>/; 934 | var aMark = $(ele).find(".name").html(); 935 | if (banned.test(aMark)) { 936 | $(ele).remove(); 937 | } 938 | }); 939 | // 主页广告 940 | $("li").each(function(){ 941 | let self = $(this); 942 | let dataType = self.attr('data-type'); 943 | if (dataType === 'ad') { 944 | self.remove(); 945 | } 946 | }); 947 | // 主页广告 948 | $("li > div > div > h2 > a[href*='https://edu.csdn.net']").parent().parent().parent().parent().remove(); 949 | $("li > div > div > h2 > a[href*='https://marketing.csdn.net']").parent().parent().parent().parent().remove(); 950 | // 官方脚本横幅 951 | $(".toolbar-advert").remove(); 952 | } else if (num === 2) { 953 | // 评论查看更多展开监听 954 | $("div.comment-list-box").css("max-height", "none"); 955 | // 屏蔽您的缩放不是100%的提示 956 | $('.leftPop').remove(); 957 | // 官方脚本横幅 958 | $(".toolbar-advert").remove(); 959 | } else if (num == 3) { 960 | // 循环删除登录提示框 961 | if ($($(".passport-login-container")[0]).length == 1 && deletedLogin == false) { 962 | let passInterval = setInterval(function() { 963 | $('.passport-login-container').hide(); 964 | console.log("hide"); 965 | }, 10); 966 | setTimeout(function() { 967 | clearInterval(passInterval); 968 | setTimeout(function() { 969 | $("#passportbox").find("img").click(); 970 | }, 500) 971 | }, 5000); 972 | deletedLogin = true; 973 | } 974 | // 红包雨 975 | $("#csdn-redpack").remove(); 976 | } 977 | }, 500); 978 | } 979 | 980 | function common(num, times) { 981 | var loop = setInterval(function () { 982 | --times; 983 | if (times <= 0) { 984 | clearInterval(loop); 985 | } 986 | if (num === 1) { 987 | // 查看更多 988 | $(".btn-readmore").removeClass("no-login"); 989 | $(".btn-readmore").addClass("fans-read-more"); 990 | $(".btn-readmore").removeAttr("href"); 991 | $(".btn-readmore").removeAttr("target"); 992 | $(".btn-readmore").removeAttr("rel"); 993 | $(".btn-readmore").click(); 994 | // 已登录用户展开评论 995 | try { 996 | document.getElementById("btnMoreComment").click(); 997 | } catch (e) {} 998 | // 删除查看更多按钮 999 | $("#btnMoreComment").parent("div.opt-box").remove(); 1000 | // 展开内容 1001 | $("div.comment-list-box").css("max-height", "none"); 1002 | // 改回背景颜色 1003 | $(".login-mark").remove(); 1004 | // 删除登录框 1005 | $(".login-box").remove(); 1006 | } else if (num === 2) { 1007 | // 挡住评论的“出头推荐” 1008 | if ($(".recommend-box").length > 1) { 1009 | $(".recommend-box")[0].remove(); 1010 | } 1011 | // 去除推广广告 1012 | $("li[data-type='ad']").remove(); 1013 | // 免登录复制 1014 | $(".hljs-button").removeClass("signin"); 1015 | $(".hljs-button").addClass("{2}"); 1016 | $(".hljs-button").attr("data-title", "免登录复制"); 1017 | $(".hljs-button").attr("onclick", "hljs.copyCode(event);setTimeout(function(){$('.hljs-button').attr('data-title', '免登录复制');},3500);"); 1018 | $("#content_views").unbind("copy"); 1019 | // 去除剪贴板劫持 1020 | $("code").attr("onclick", "mdcp.copyCode(event)"); 1021 | try { 1022 | // 复制时保留原文格式,参考 https://greasyfork.org/en/scripts/390502-csdnremovecopyright/code 1023 | Object.defineProperty(window, "articleType", { 1024 | value: 0, 1025 | writable: false, 1026 | configurable: false 1027 | }); 1028 | } catch (err) { 1029 | } 1030 | csdn.copyright.init("", "", ""); 1031 | // 页头广告 1032 | try { 1033 | document.getElementsByClassName("column-advert-box")[0].style.display="none"; 1034 | } catch (e) {} 1035 | // 自动检测是否有目录,如果没有则删除右边栏,文章居中 1036 | if ($(".recommend-right_aside").html() && $(".recommend-right_aside").html().replace(/[\r\n]/g, "").replace(/(\s)/g, "") === "") { 1037 | $("#rightAside").remove(); 1038 | } else if ($(".recommend-right_aside").html() && $("#recommend-right").html().replace(/[\r\n]/g, "").replace(/(\s)/g, "") === "") { 1039 | $("#rightAside").remove(); 1040 | } 1041 | // 登录按钮文字太多,修改 1042 | $("a").each(function() { 1043 | if ($(this).attr('href') === 'https://passport.csdn.net/account/login') { 1044 | $(this).html('登入'); 1045 | } 1046 | }); 1047 | // 顶栏广告 1048 | $("li").each(function(){ 1049 | let self = $(this); 1050 | let dataType = self.attr('data-sub-menu-type'); 1051 | if (dataType === 'vip') { 1052 | self.remove(); 1053 | } 1054 | let dataTitle = self.attr('title'); 1055 | if (dataTitle === '高价值源码课程分享' || dataTitle === '系统学习·问答·比赛' || dataTitle === '简单高效优惠的云服务') { 1056 | self.remove(); 1057 | } 1058 | }); 1059 | // 顶栏VIP选项 1060 | $('.toolbar-subMenu-box').find("[href='https://mall.csdn.net/vip']").parent().remove(); 1061 | } else if (num == 3) { 1062 | //论坛自动展开 1063 | $(".js_show_topic").click(); 1064 | } else if (num == 4) { 1065 | /** 配置控制 **/ 1066 | let config = new Config(); 1067 | let smCookie = config.get("scr-sm", true); 1068 | let mdCookie = config.get("scr-md", false); 1069 | let lgCookie = config.get("scr-lg", false); 1070 | let foCookie = config.get("scr-fo", false) 1071 | 1072 | $("#scr-sm").prop("checked", smCookie); 1073 | $("#scr-md").prop("checked", mdCookie); 1074 | $("#scr-lg").prop("checked", lgCookie); 1075 | $("#scr-fo").prop("checked", foCookie); 1076 | 1077 | if (smCookie) { 1078 | // Small Screen Mode 1079 | $(".main_father").removeClass("justify-content-center"); 1080 | GM_addStyle(` 1081 | main{ 1082 | width: auto!important; 1083 | float: none!important; 1084 | max-width: 90vw; 1085 | } 1086 | main article img{ 1087 | margin: 0 auto; 1088 | max-width: 100%; 1089 | object-fit: cover; 1090 | } 1091 | `); 1092 | $("#mainBox").css("width", "100%"); 1093 | } else if (mdCookie) { 1094 | // Middle Screen Mode 1095 | $(".main_father").removeClass("justify-content-center"); 1096 | } else if (lgCookie) { 1097 | // Large Screen Mode 1098 | $(".container").css("margin", "0 auto") 1099 | } else if (foCookie) { 1100 | // Focus mode 1101 | $(".recommend-right").remove(); 1102 | $(".container").css("width", "100%"); 1103 | $(".container > main").css("width", "100%"); 1104 | } 1105 | 1106 | // 屏幕尺寸单选监听 1107 | $("#scr-sm").click(function () { 1108 | new Config().set("scr-sm", true); 1109 | new Config().set("scr-md", false); 1110 | new Config().set("scr-lg", false); 1111 | new Config().set("scr-fo", false); 1112 | }); 1113 | $("#scr-md").click(function () { 1114 | new Config().set("scr-md", true); 1115 | new Config().set("scr-sm", false); 1116 | new Config().set("scr-lg", false); 1117 | new Config().set("scr-fo", false); 1118 | }); 1119 | $("#scr-lg").click(function () { 1120 | new Config().set("scr-lg", true); 1121 | new Config().set("scr-sm", false); 1122 | new Config().set("scr-md", false); 1123 | new Config().set("scr-fo", false); 1124 | }); 1125 | $("#scr-fo").click(function () { 1126 | new Config().set("scr-fo", true); 1127 | new Config().set("scr-sm", false); 1128 | new Config().set("scr-md", false); 1129 | new Config().set("scr-lg", false); 1130 | }); 1131 | // 判断是否为登录状态 1132 | if ($('.toolbar-btn-loginfun').text() === '登录') { 1133 | // 未登录删除无用按钮 1134 | $("a:contains('消息')").parent().parent()[0].remove(); 1135 | $(".toolbar-btn-collect").remove(); 1136 | $(".toolbar-btn-write").remove(); 1137 | $(".toolbar-btn-mp").remove(); 1138 | } 1139 | $("a:contains('会员12.12')").parent().remove(); 1140 | $(".toolbar-btn-vip").remove(); 1141 | } else if (num == 5) { 1142 | // 改回背景颜色 1143 | $(".login-mark").remove(); 1144 | // 删除登录框 1145 | $(".login-box").remove(); 1146 | } else if (num == 6) { 1147 | let did = false; 1148 | let configHTML = ''; 1149 | configHTML += '

CSDNGreener V' + version + ' ' + settings_svg + '

'; 1150 | configHTML += '

官方 QQ 交流群:1042370453


'; 1151 | 1152 | // 设定:推荐内容按钮 1153 | configHTML += '

根据屏幕尺寸,适配版式

建议逐个尝试后选择适合你的版式,屏幕过小或者版式选择不正确右侧栏可能没有空间显示,导致侧栏定制无效(请尝试调节浏览器缩放,快捷键 Ctrl+鼠标滚轮)。

'; 1154 | configHTML += ''; 1155 | configHTML += ''; 1156 | configHTML += ''; 1157 | configHTML += ''; 1158 | configHTML += '
'; 1159 | configHTML += '

通用设定

'; 1160 | configHTML += '

自定义背景图:

'; 1161 | configHTML += ' '; 1162 | configHTML += '
'; 1163 | configHTML += ' '; 1164 | configHTML += '
'; 1165 | configHTML += ' '; 1166 | configHTML += '
'; 1167 | configHTML += ' '; 1168 | configHTML += '
'; 1169 | configHTML += ' '; 1170 | configHTML += '
'; 1171 | configHTML += ' '; 1172 | configHTML += '
'; 1173 | configHTML += ' '; 1174 | configHTML += '
'; 1175 | configHTML += '
'; 1176 | configHTML += '

右侧栏定制

'; 1177 | configHTML += ' '; 1178 | configHTML += '
'; 1179 | configHTML += ' '; 1180 | configHTML += '
'; 1181 | configHTML += ' '; 1182 | configHTML += '
'; 1183 | configHTML += ' '; 1184 | configHTML += '
'; 1185 | configHTML += ' '; 1186 | configHTML += '
'; 1187 | configHTML += ' '; 1188 | configHTML += '
'; 1189 | configHTML += ' '; 1190 | configHTML += '
'; 1191 | configHTML += ' '; 1192 | configHTML += '
'; 1193 | configHTML += ' '; 1194 | configHTML += '
'; 1195 | configHTML += ' '; 1196 | configHTML += '

'; 1197 | configHTML += '
要不要来看看 :)

(作者本人建设的社区~

社区中聚集了同行业的大佬小白,欢迎小伙伴们一起摸鱼!

'; 1198 | configHTML += '
☕ 如果您觉得脚本好用,欢迎请我喝杯咖啡,我将努力更新脚本功能 ❤️
'; 1199 | configHTML += '' + star_svg + ' 点我~ 动动小手在 GitHub 点个 Star 和关注,支持我继续维护脚本 :)

'; 1200 | configHTML += '

特别提示:CSDNGreener 脚本不提供任何会员文章破解、会员资源下载功能,仅适用于前端优化,请在CSDN官方渠道购买CSDN会员体验付费功能。

'; 1201 | configHTML += '
'; 1202 | configHTML += '
'; 1203 | 1204 | // configHTML += '' + donate_svg + ' 我是老板,投币打赏'; 1205 | configHTML += '
'; 1206 | let saveButton = ''; 1207 | // 绿化器设定 1208 | $("body").after('
' + saveButton + configHTML); 1209 | 1210 | /** 配置控制 **/ 1211 | // 推荐内容 1212 | $(".blog-content-box").append("
"); 1213 | $("#recommendSwitch:last").append(' ' + 1214 | '

显示推荐内容

'); 1215 | let recommendCookie = config.get("recommend", false); 1216 | if (!recommendCookie) { 1217 | $(".recommend-box").hide(); 1218 | } 1219 | if (recommendCookie) { 1220 | $("#toggle-recommend-button").prop("checked", true); 1221 | $("#toggle-button").prop("checked", true); 1222 | } else { 1223 | $("#toggle-recommend-button").prop("checked", false); 1224 | $("#toggle-button").prop("checked", false); 1225 | } 1226 | config.listenButton("#toggle-recommend-button", "recommend", 1227 | function() {$(".recommend-box").slideDown(200);}, 1228 | function() {$(".recommend-box").slideUp(200);}); 1229 | config.listenButtonAndAction("#toggle-button", "recommend", 1230 | function() {$(".recommend-box").slideDown(200);}, 1231 | function() {$(".recommend-box").slideUp(200);}); 1232 | 1233 | // 显示小店 1234 | let shopCookie = config.get('shop',false); 1235 | if(!shopCookie){ 1236 | $("#csdn-shop-window").hide(); 1237 | $("#csdn-shop-window-top").hide(); 1238 | } 1239 | if (shopCookie) { 1240 | $("#toggle-shop-button").prop("checked", true); 1241 | } else { 1242 | $("#toggle-shop-button").prop("checked", false); 1243 | } 1244 | config.listenButton("#toggle-shop-button", "shop", 1245 | function() {location.reload();}, 1246 | function() {location.reload();}); 1247 | // 侧栏小广告 1248 | let adCookie = config.get("ad", true); 1249 | if (adCookie) { 1250 | setTimeout(function() { 1251 | // $("#recommend-right").append('

来自 CSDN 脚本的小广告

  • 您可在 脚本设置 中永久关闭小广告
    感谢您的支持 ❤️

    29元每月!CTGNet GIA 回程五网高端CN2 GIA/GT网络,支持VPC高级网络
    拒绝绕路,拒绝不稳定,助力企业拓展全球业务
    安全,稳定,高性能

'); 1252 | }, 500); 1253 | } 1254 | if (adCookie) { 1255 | $("#toggle-ad-button").prop("checked", true); 1256 | } else { 1257 | $("#toggle-ad-button").prop("checked", false); 1258 | } 1259 | config.listenButton("#toggle-ad-button", "ad", 1260 | function() {location.reload();}, 1261 | function() {location.reload();}); 1262 | // 显示作者名片 1263 | let authorCardCookie = config.get("authorCard", true); 1264 | if (authorCardCookie) { 1265 | // 博主信息 1266 | $('#recommend-right').append($('#asideProfile').prop("outerHTML")); 1267 | setTimeout(function() { 1268 | $('#asideProfile').attr("style", "margin-top: 8px; width: 300px;"); 1269 | }, 500); 1270 | } 1271 | if (authorCardCookie) { 1272 | $("#toggle-authorcard-button").prop("checked", true); 1273 | } else { 1274 | $("#toggle-authorcard-button").prop("checked", false); 1275 | } 1276 | config.listenButton("#toggle-authorcard-button", "authorCard", 1277 | function() {location.reload();}, 1278 | function() {location.reload();}); 1279 | 1280 | // 强制白色主题 1281 | let whiteThemeCookie = config.get("whiteTheme", false); 1282 | if (whiteThemeCookie) { 1283 | // 背景删除 1284 | $('.main_father').attr('style', 'background-image: none !important; background-color: #f5f6f7; background: #f5f6f7;'); 1285 | $('[href^="https://csdnimg.cn/release/phoenix/template/themes_skin/"]').attr('href', 'https://csdnimg.cn/release/phoenix/template/themes_skin/skin-technology/skin-technology-6336549557.min.css'); 1286 | $('#csdn-toolbar').removeClass('csdn-toolbar-skin-black'); 1287 | $('.csdn-logo').attr('src', '//csdnimg.cn/cdn/content-toolbar/csdn-logo.png?v=20200416.1'); 1288 | $('html').css('background-color', '#f5f6f7'); 1289 | } 1290 | if (whiteThemeCookie) { 1291 | $("#toggle-whitetheme-button").prop("checked", true); 1292 | } else { 1293 | $("#toggle-whitetheme-button").prop("checked", false); 1294 | } 1295 | config.listenButton("#toggle-whitetheme-button", "whiteTheme", 1296 | function() {location.reload();}, 1297 | function() {location.reload();}); 1298 | 1299 | // 背景图 1300 | let backgroundImage = GM_getValue("backgroundImage", ""); 1301 | if (backgroundImage !== "") { 1302 | $("#backgroundImgUrl").val(backgroundImage); 1303 | $(".main_father").attr('style', 'background-image:url(' + backgroundImage + ');background-attachment:fixed;background-size:100%;'); 1304 | } 1305 | $('#backgroundImgUrl').on('input', function() { 1306 | GM_setValue("backgroundImage", $("#backgroundImgUrl").val()); 1307 | }); 1308 | $('#backgroundImgUrl').on('change', function() { 1309 | GM_setValue("backgroundImage", $("#backgroundImgUrl").val()); 1310 | }); 1311 | $("#upload_bg").on('change', function() { 1312 | let file = $("#upload_bg")[0].files[0]; 1313 | let reader = new FileReader(); 1314 | reader.onloadend = function (e) { 1315 | let base64 = e.target.result; 1316 | $('#backgroundImgUrl').val(base64); 1317 | $('#backgroundImgUrl').change(); 1318 | } 1319 | reader.readAsDataURL(file); 1320 | }); 1321 | 1322 | // 搜博主文章 1323 | let searchBlogCookie = config.get("searchBlog", false); 1324 | if(searchBlogCookie) { 1325 | $('#recommend-right').append($('#asideSearchArticle').prop("outerHTML")); 1326 | setTimeout(function() { 1327 | $('#asideSearchArticle').attr("style", "margin-top: 8px; width: 300px;"); 1328 | var i = $("#search-blog-words") 1329 | , n = $(".btn-search-blog"); 1330 | i.keyup(function(t) { 1331 | var n = t.keyCode; 1332 | if (13 == n) { 1333 | var e = encodeURIComponent(i.val()); 1334 | if (e) { 1335 | var s = "//so.csdn.net/so/search/s.do?q=" + e + "&t=blog&u=" + username; 1336 | window.open(s) 1337 | } 1338 | } 1339 | }); 1340 | n.on("click", function(t) { 1341 | var n = encodeURIComponent(i.val()); 1342 | if (n) { 1343 | var e = "//so.csdn.net/so/search/s.do?q=" + n + "&t=blog&u=" + username; 1344 | window.open(e) 1345 | } 1346 | t.preventDefault() 1347 | }); 1348 | }, 500); 1349 | } 1350 | if (searchBlogCookie) { 1351 | $("#toggle-searchblog-button").prop("checked", true); 1352 | } else { 1353 | $("#toggle-searchblog-button").prop("checked", false); 1354 | } 1355 | config.listenButton("#toggle-searchblog-button", "searchBlog", 1356 | function() {location.reload();}, 1357 | function() {location.reload();}); 1358 | 1359 | // 最新文章 1360 | let newArticleCookie = config.get("newArticle", false); 1361 | if (newArticleCookie) { 1362 | $('#recommend-right').append($('#asideNewArticle').prop("outerHTML")); 1363 | setTimeout(function() { 1364 | $('#asideNewArticle').attr("style", "margin-top: 8px; width: 300px;"); 1365 | }, 0); 1366 | } 1367 | if (newArticleCookie) { 1368 | $("#toggle-newarticle-button").prop("checked", true); 1369 | } else { 1370 | $("#toggle-newarticle-button").prop("checked", false); 1371 | } 1372 | config.listenButton("#toggle-newarticle-button", "newArticle", 1373 | function() {location.reload();}, 1374 | function() {location.reload();}); 1375 | 1376 | // 热门文章 1377 | let hotArticleCookie = config.get("hotArticle", false); 1378 | if (hotArticleCookie) { 1379 | $('#recommend-right').append($("#asideHotArticle").prop("outerHTML")); 1380 | setTimeout(function() { 1381 | $('#asideHotArticle').attr("style", "margin-top: 8px; width: 300px;"); 1382 | $('#asideHotArticle img').remove(); 1383 | }, 0); 1384 | } 1385 | if (hotArticleCookie) { 1386 | $("#toggle-hotarticle-button").prop("checked", true); 1387 | } else { 1388 | $("#toggle-hotarticle-button").prop("checked", false); 1389 | } 1390 | config.listenButton("#toggle-hotarticle-button", "hotArticle", 1391 | function() {location.reload();}, 1392 | function() {location.reload();}); 1393 | 1394 | // 最新评论 1395 | let newCommentsCookie = config.get("newComments", false); 1396 | if (newCommentsCookie) { 1397 | $('#recommend-right').append($("#asideNewComments").prop("outerHTML")); 1398 | setTimeout(function() { 1399 | $('#asideNewComments').attr("style", "margin-top: 8px; width: 300px;"); 1400 | $(".comment.ellipsis").attr("style", "max-height: none;"); 1401 | $(".title.text-truncate").attr("style", "padding: 0"); 1402 | }, 0); 1403 | } 1404 | if (newCommentsCookie) { 1405 | $("#toggle-newcomments-button").prop("checked", true); 1406 | } else { 1407 | $("#toggle-newcomments-button").prop("checked", false); 1408 | } 1409 | config.listenButton("#toggle-newcomments-button", "newComments", 1410 | function() {location.reload();}, 1411 | function() {location.reload();}); 1412 | 1413 | // 分类专栏 1414 | let kindPersonCookie = config.get("kindPerson", false); 1415 | if (!kindPersonCookie) { 1416 | setTimeout(function() { 1417 | $('#asideCategory').remove(); 1418 | $('.kind_person').remove(); 1419 | }, 0); 1420 | } else { 1421 | $('#recommend-right').append($("#asideCategory").prop("outerHTML")); 1422 | if ($("#asideCategory").length > 0) { 1423 | $('.kind_person').remove(); 1424 | } else { 1425 | $('.kind_person').attr("style", "margin-top: 8px; width: 300px; height:255px;"); 1426 | } 1427 | setTimeout(function() { 1428 | $('#asideCategory').attr("style", "margin-top: 8px; width: 300px; display:block !important;"); 1429 | $("a.flexible-btn").click(function() { 1430 | $(this).parents('div.aside-box').removeClass('flexible-box'); 1431 | $(this).parents("p.text-center").remove(); 1432 | }) 1433 | }, 500); 1434 | } 1435 | if (kindPersonCookie) { 1436 | $("#toggle-kindperson-button").prop("checked", true); 1437 | } else { 1438 | $("#toggle-kindperson-button").prop("checked", false); 1439 | } 1440 | config.listenButton("#toggle-kindperson-button", "kindPerson", 1441 | function() {location.reload();}, 1442 | function() {location.reload();}); 1443 | 1444 | // 目录 1445 | let contentCookie = config.get("content", true); 1446 | if (!contentCookie) { 1447 | setTimeout(function() { 1448 | $('.align-items-stretch.group_item').parent().remove(); 1449 | }, 0); 1450 | } 1451 | if (contentCookie) { 1452 | $("#toggle-content-button").prop("checked", true); 1453 | } else { 1454 | $("#toggle-content-button").prop("checked", false); 1455 | } 1456 | config.listenButton("#toggle-content-button", "content", 1457 | function() {location.reload();}, 1458 | function() {location.reload();}); 1459 | 1460 | // 推荐文章 1461 | let recommendArticleCookie = config.get("recommendArticle", false); 1462 | if (!recommendArticleCookie) { 1463 | setTimeout(function() { 1464 | $('.recommend-list-box').remove(); 1465 | }, 0); 1466 | } else { 1467 | setTimeout(function() { 1468 | $('.recommend-list-box').attr("style", "margin-top: 8px; width: 300px; height:255px;"); 1469 | }, 0); 1470 | } 1471 | if (recommendArticleCookie) { 1472 | $("#toggle-recommendarticle-button").prop("checked", true); 1473 | } else { 1474 | $("#toggle-recommendarticle-button").prop("checked", false); 1475 | } 1476 | config.listenButton("#toggle-recommendarticle-button", "recommendArticle", 1477 | function() {location.reload();}, 1478 | function() {location.reload();}); 1479 | 1480 | // 归档 1481 | let archiveCookie = config.get("archive", false); 1482 | if (!archiveCookie) { 1483 | setTimeout(function() { 1484 | $('#asideArchive').remove(); 1485 | }, 0); 1486 | } else { 1487 | $('#recommend-right').append($("#asideArchive").prop("outerHTML")); 1488 | setTimeout(function() { 1489 | $('#asideArchive').attr("style", "margin-top: 8px; width: 300px; display:block !important;"); 1490 | }, 500); 1491 | } 1492 | if (archiveCookie) { 1493 | $("#toggle-archive-button").prop("checked", true); 1494 | } else { 1495 | $("#toggle-archive-button").prop("checked", false); 1496 | } 1497 | config.listenButton("#toggle-archive-button", "archive", 1498 | function() {location.reload();}, 1499 | function() {location.reload();}); 1500 | 1501 | // 自动靠左平铺 1502 | let autoSizeCookie = config.get("autoSize", false); 1503 | if (autoSizeCookie) { 1504 | setInterval(function () { 1505 | // 文章宽度自适应 1506 | if (window.innerWidth < 1100) { 1507 | // 删除原有响应式样式 1508 | $(".main_father").removeClass("justify-content-center"); 1509 | $("article").width(window.innerWidth - 150); 1510 | GM_addStyle(` 1511 | main{ 1512 | width: auto!important; 1513 | float: none!important; 1514 | max-width: 90vw; 1515 | } 1516 | main article img{ 1517 | margin: 0 auto; 1518 | max-width: 100%; 1519 | object-fit: cover; 1520 | } 1521 | `); 1522 | did = true; 1523 | } else { 1524 | if (did === true) { 1525 | $("article").removeAttr("style"); 1526 | did = false; 1527 | } 1528 | } 1529 | }, 500); 1530 | } 1531 | if (autoSizeCookie) { 1532 | $("#toggle-autosize-button").prop("checked", true); 1533 | } else { 1534 | $("#toggle-autosize-button").prop("checked", false); 1535 | } 1536 | config.listenButton("#toggle-autosize-button", "autoSize", 1537 | function() {location.reload();}, 1538 | function() {location.reload();}); 1539 | 1540 | // 自动隐藏顶栏 1541 | let autoHideToolbarCookie = config.get("autoHideToolbar", true); 1542 | if (autoHideToolbarCookie) { 1543 | $(window).scroll(function() { 1544 | if (document.documentElement.scrollTop > 100) { 1545 | let scrollS = $(this).scrollTop(); 1546 | if (scrollS >= windowTop) { 1547 | $('#csdn-toolbar').slideUp(100); 1548 | windowTop = scrollS; 1549 | } else { 1550 | $('#csdn-toolbar').slideDown(100); 1551 | windowTop = scrollS; 1552 | } 1553 | } 1554 | }); 1555 | } 1556 | if (autoHideToolbarCookie) { 1557 | $("#toggle-autohidetoolbar-button").prop("checked", true); 1558 | } else { 1559 | $("#toggle-autohidetoolbar-button").prop("checked", false); 1560 | } 1561 | config.listenButton("#toggle-autohidetoolbar-button", "autoHideToolbar", 1562 | function() {location.reload();}, 1563 | function() {location.reload();}); 1564 | 1565 | // 自动隐藏底栏 1566 | let autoHideBottomBarCookie = config.get("autoHideBottomBar", true); 1567 | if (autoHideBottomBarCookie) { 1568 | $("#toolBarBox .left-toolbox").css({ 1569 | position: "relative", 1570 | left: "0px", 1571 | bottom: "0", 1572 | width: $("#toolBarBox").width() + "px" 1573 | }); 1574 | $(window).scroll(function() { 1575 | $("#toolBarBox .left-toolbox").css({ 1576 | position: "relative", 1577 | left: "0px", 1578 | bottom: "0", 1579 | width: $("#toolBarBox").width() + "px" 1580 | }) 1581 | }); 1582 | } 1583 | if (autoHideBottomBarCookie) { 1584 | $("#toggle-autohidebottombar-button").prop("checked", true); 1585 | } else { 1586 | $("#toggle-autohidebottombar-button").prop("checked", false); 1587 | } 1588 | config.listenButton("#toggle-autohidebottombar-button", "autoHideBottomBar", 1589 | function() {location.reload();}, 1590 | function() {location.reload();}); 1591 | 1592 | // 创作中心按钮 1593 | let writeBlogCookie = config.get("writeBlog", true); 1594 | if (!writeBlogCookie) { 1595 | $(".toolbar-btn-write").remove(); 1596 | } 1597 | if (writeBlogCookie) { 1598 | $("#toggle-writeblog-button").prop("checked", true); 1599 | } else { 1600 | $("#toggle-writeblog-button").prop("checked", false); 1601 | } 1602 | config.listenButton("#toggle-writeblog-button", "writeBlog", 1603 | function() {location.reload();}, 1604 | function() {location.reload();}); 1605 | 1606 | // 右侧滚动条 1607 | /** setTimeout(function () { 1608 | let rightSideHeight = 0; 1609 | let pageHeight = $(window).height(); 1610 | rightSideHeight += getHeight($('.align-items-stretch.group_item').parent()); 1611 | rightSideHeight += getHeight($("#asideProfile")); 1612 | rightSideHeight += getHeight($("#asideSearchArticle")); 1613 | rightSideHeight += getHeight($("#asideNewArticle")); 1614 | rightSideHeight += getHeight($("#asideHotArticle")); 1615 | rightSideHeight += getHeight($("#asideNewComments")); 1616 | rightSideHeight += getHeight($("#asideCategory")); 1617 | rightSideHeight += getHeight($("#asideArchive")); 1618 | console.debug("Right side total height: " + rightSideHeight); 1619 | console.debug("Page height: " + pageHeight); 1620 | if (rightSideHeight > pageHeight) { 1621 | $('#recommend-right').css("overflow", "scroll"); 1622 | } 1623 | }, 1500); */ 1624 | } else if (num === 7) { 1625 | $(".me_r")[1].remove(); 1626 | } else if (num === 8) { 1627 | /* $(".article-bar-top").append("
"); 1628 | $(".article-bar-top").append($(".aside-box-footerClassify").children("dd").html()); 1629 | $("dl").each(function (index, element) { 1630 | var key = $(this).children("dt"); 1631 | var value = $(this).children("dd").children("span"); 1632 | if (key.html().indexOf("原创") != -1) { 1633 | key = $(this).children("dt").children("a") 1634 | value = $(this).children("dd").children("a").children("span"); 1635 | addInfo(key, value); 1636 | } else 1637 | if (value.html() != undefined) { 1638 | addInfo(key, value); 1639 | } 1640 | } ); 1641 | function addInfo(key, value) { 1642 | var bind = key.html() + " " + value.html() + "  "; 1643 | $(".article-bar-top").append(bind + " "); 1644 | } */ 1645 | $(".blog_container_aside").remove(); 1646 | $(".toolbox-left > .profile-attend").remove(); 1647 | 1648 | // 标题消息提醒去除 1649 | let title = document.title.replace(/^\(.*?\)/g, ""); 1650 | document.title = title; 1651 | // 评论复制按钮 1652 | $('.comment-box').prepend(''); 1653 | $('.new-opt-box.new-opt-box-bg').prepend('复制评论'); 1654 | $('.btn-copy').click(function() { 1655 | var clipboard = new ClipboardJS('.comment-hidden-text'); 1656 | clipboard.on('success', function(e) { 1657 | console.info('Action:', e.action); 1658 | console.info('Text:', e.text); 1659 | console.info('Trigger:', e.trigger); 1660 | e.clearSelection(); 1661 | $('.btn-copy').html('成功'); 1662 | setTimeout(function() { 1663 | $('.btn-copy').html('复制评论'); 1664 | }, 1000); 1665 | }); 1666 | clipboard.on('error', function(e) { 1667 | console.error('Action:', e.action); 1668 | console.error('Trigger:', e.trigger); 1669 | $('.btn-copy').html('失败,请手动复制'); 1670 | setTimeout(function() { 1671 | $('.btn-copy').html('复制评论'); 1672 | }, 1000); 1673 | }); 1674 | $(".comment-hidden-text").click(); 1675 | clipboard.destroy(); 1676 | }); 1677 | } else if (num === 9) { 1678 | // 删除CSDN LOGO悬浮后的二维码 1679 | $(".toolbar-subMenu > img").parent().remove(); 1680 | } 1681 | }, 100); 1682 | progressor.incProgress(10); 1683 | } 1684 | 1685 | function showTips() { 1686 | var config = { 1687 | content: "欢迎使用 CSDNGreener,绿化设定按钮在这里!
好的,以后不再提示我", 1688 | type: "html", 1689 | alignTo: ["bottom", "right"], 1690 | trigger: "show", 1691 | isclose: false, 1692 | color: ["#B2E281", "#B2E281"] 1693 | }; 1694 | $("#greenerSettings").showTips(config); 1695 | } 1696 | 1697 | function getHeight(element) { 1698 | let outerHeight = element.outerHeight(); 1699 | if (outerHeight === null) { 1700 | return 0; 1701 | } 1702 | return outerHeight; 1703 | } 1704 | 1705 | function isFirefox() { 1706 | return navigator.userAgent.indexOf("Firefox") > 0; 1707 | } 1708 | -------------------------------------------------------------------------------- /csdngreener_openuserjs.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @author AdlerED 3 | // @copyright 2020, adlered https://stackoverflow.wiki 4 | // @icon https://csdnimg.cn/public/favicon.ico 5 | // @homepageURL https://github.com/adlered/CSDNGreener 6 | // @supportURL https://github.com/adlered/CSDNGreener/issues/new?assignees=adlered&labels=help+wanted&template=ISSUE_TEMPLATE.md&title= 7 | // @contributionURL https://doc.stackoverflow.wiki/web/#/21?page_id=138 8 | // @name 最强的老牌脚本CSDNGreener:CSDN广告完全过滤、人性化脚本优化 9 | // @namespace https://github.com/adlered 10 | // @version 4.2.3 11 | // @description 全新4.0版本!拥有数项独家功能的最强CSDN脚本,不服比一比|无需登录CSDN,获得比会员更佳的体验|背景图自定义,模块化卡片,显示什么你决定|分辨率自适配,分屏不用滚动|超级预优化|独家原创文章免登录展开|独家推荐内容自由开关|独家免登录复制|独家防外链重定向|独家论坛未登录自动展开文章、评论|全面净化|沉浸阅读|净化剪贴板 12 | // @connect www.csdn.net 13 | // @include *://*.csdn.net/* 14 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery-cookie/1.4.1/jquery.cookie.min.js 15 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/nprogress/0.2.0/nprogress.min.js 16 | // @require https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/clipboard.js/2.0.10/clipboard.min.js 17 | // @updateURL https://github.com/adlered/CSDNGreener/raw/master/csdngreener_openuserjs.user.js 18 | // @grant GM_addStyle 19 | // @grant GM_setValue 20 | // @grant GM_getValue 21 | // @license AGPL-3.0-or-later 22 | // @antifeature ads CSDNGreener 脚本中嵌入了可一键永久关闭的小广告,不会影响您的使用体验:) 请放心安装! 23 | // @note 24-03-28 4.2.3 跟随更新 24 | // @note 23-12-21 4.2.2 修复了一些已知问题 25 | // @note 23-12-16 4.2.1 文章页牛皮癣优化 26 | // @note 23-12-15 4.2.0 优化顶栏显示内容,修复了若干由于CSDN前端变化导致优化失效的问题 27 | // @note 23-05-25 4.1.9 再次修复免登录复制无法使用的问题 28 | // @note 23-05-11 4.1.8 强杀变异型登录框弹出(不影响自己点击登录使用) 29 | // @note 23-05-10 4.1.7 增强免登录复制功能 30 | // @note 23-04-11 4.1.6 去广告更新 31 | // @note 23-04-06 4.1.5 新增: 跳过 CSDN 的 link 页面 32 | // @note 23-04-04 4.1.4 增加ads标识 33 | // @note 23-03-30 4.1.3 移除统计代码,登录问题相关优化(只屏蔽一次) 34 | // @note 23-02-03 4.1.2 修复了无法登录的问题(评论不登录无法加载暂无解决方案,我们在持续努力中) 35 | // @note 22-05-30 4.1.1 功能修复,广告屏蔽 36 | // @note 22-01-18 4.1.0 代码折叠适配 37 | // @note 22-01-05 4.0.9 更新广告 38 | // @note 21-12-12 4.0.8 屏蔽学生认证 39 | // @note 21-10-21 4.0.7 屏蔽红包雨 40 | // @note 21-09-24 4.0.6 修复登录弹窗无法彻底去除的问题 41 | // @note 21-09-20 4.0.5 增加自定义背景功能 42 | // @note 21-09-13 4.0.4 增加一个没有收钱的广告(在设置里,不影响体验) 43 | // @note 21-09-01 4.0.3 增加用户使用情况统计模块 44 | // @note 21-08-25 4.0.2 修复右侧置顶栏按钮消失的问题 45 | // @note 21-08-21 4.0.1 去除右侧悬浮栏,优化脚本 46 | // @note 21-08-20 4.0.0 全新4.0发布!UI美化,代码优化,兼容Firefox,更多排版模式 47 | // @note 21-08-20 3.5.7 修复无法完整复制、保存csdn的网页会跳转首页的问题 48 | // @note 21-08-19 3.5.6 自动隐藏底栏功能改为始终隐藏底栏 49 | // @note 21-08-18 3.5.5 修复无法选择复制的问题 50 | // @note 21-06-17 3.5.4 去除右侧红包悬浮窗 51 | // @note 21-04-18 3.5.3 增加显示小店的设定 52 | // @note 21-03-13 3.5.2 去主页广告,去文章页面推荐内容Title 53 | // @note 21-03-01 3.5.1 修改文案 54 | // @note 21-02-06 3.5.0 修复上传资源界面标签选择消失的问题 55 | // @note 21-01-17 3.4.9 删除文章页和论坛广告,暂时停用右侧栏滚动功能(CSDN限制) 56 | // @note 21-01-15 3.4.8 保存按钮优化,修复显示创作中心按钮功能失效的问题 57 | // @note 21-01-15 3.4.7 改进脚本细节,增加广告屏蔽能力,修复绿化按钮错位的问题 58 | // @note 20-12-25 3.4.6 主页部分嵌入式广告删除 59 | // @note 20-12-18 3.4.5 修复绿化设定按钮排版不正确的问题 60 | // @note 20-12-15 3.4.4 修复了某些子页显示不正常的问题 61 | // @note 20-10-23 3.4.3 适应新版CSDN,去除主页和登录页广告,以及登录提示,并移除底部信息 62 | // @note 20-10-20 3.4.2 删除右侧广告 63 | // @note 20-09-26 3.4.1 修改排版设定,修复登录框弹出的问题 64 | // @note 20-09-24 3.4.0 紧急修复由于CSDN前端样式修改导致设定开关丢失的问题 65 | // @note 20-08-27 3.3.9 紧急修复由于CSDN前端样式修改导致脚本失效的问题 66 | // @note 20-08-26 3.3.8 合法脚本提示 67 | // @note 20-07-20 3.3.7 修复菜单栏在创作中心显示异常的问题 68 | // @note 20-07-18 3.3.6 工具箱按钮优化 69 | // @note 20-07-05 3.3.5 评论复制功能交互优化 70 | // @note 20-07-04 3.3.4 修复右侧栏消失的问题 71 | // @note 20-07-03 3.3.3 新增复制评论功能!删除顶部广告 72 | // @note 20-06-28 3.3.2 提示修改 73 | // @note 20-06-27 3.3.1 弹窗提示逻辑修改为仅提示一次。 74 | // @note 20-06-27 3.3.0 网站标题新消息提醒去除 75 | // @note 20-06-24 3.2.9 控制台文字可以点击了,修改自动版式描述语义 76 | // @note 20-06-24 3.2.8 屏幕尺寸选择,控制台版式修改,若干问题修复 77 | // @note 20-06-23 3.2.7 右侧栏滚动条显示方式优化 78 | // @note 20-06-23 3.2.6 文章居中模式可选 79 | // @note 20-06-22 3.2.5 右侧没有可显示内容时,文章居中 80 | // @note 20-06-22 3.2.4 文章居中 81 | // @note 20-06-22 3.2.3 右侧栏加入滚动条,脚本主页URL修改,下载页和主页广告去除 82 | // @note 20-06-22 3.2.2 Dark Reader兼容模式,自动隐藏顶栏优化,热门文章和最新评论卡片布局调整 83 | // @note 20-06-21 3.2.1 脚本迁移版本迭代 84 | // @note 20-06-21 3.1.9 增加自动隐藏底栏功能 85 | // @note 20-06-21 3.1.8 增加自动隐藏顶栏功能,修复选项窗口被点赞长条挡住的Bug,选项窗口布局修改 86 | // @note 20-06-20 3.1.7 设置窗口大小固定,增加打赏入口 87 | // @note 20-06-19 3.1.6 显示推荐内容按钮回归,新布局紧急修复 88 | // @note 20-06-18 3.1.5 自定义功能更新 89 | // @note 20-06-16 3.1.4 支持大部分功能模块化显示 90 | // @note 20-06-14 3.1.3 绿化设定优化 91 | // @note 20-06-14 3.1.2 ISSUE模板调整Support URL 92 | // @note 20-06-14 3.1.1 增加搜博主文章模块 93 | // @note 20-06-13 3.1.0 修复设置过期的问题 94 | // @note 20-06-12 3.0.9 标题回滚 95 | // @note 20-06-12 3.0.8 主页广告删除,绿化设置仅显示在文章页面,删除页脚,顶部优化,若干细节优化 96 | // @note 20-06-11 3.0.7 增加官方QQ交流群,增加关闭强制白色主题功能 97 | // @note 20-06-11 3.0.6 用户名片功能优化 98 | // @note 20-06-11 3.0.5 优化加载速度 99 | // @note 20-06-10 3.0.4 修复设置界面遮挡的问题,显示博主头像 100 | // @note 20-06-09 3.0.3 默认设定修改 101 | // @note 20-06-09 3.0.2 修复推荐内容按钮刷新不生效的问题,增加工具箱提示框 102 | // @note 20-06-08 3.0.1 设置中心推出!增加浏览效果选项 && Green Book Icon Update 103 | // @note 20-06-08 3.0.0 设置中心推出!增加浏览效果选项 104 | // @note 20-06-07 2.4.2 设置解耦,下个版本搞配置中心 105 | // @note 20-06-06 2.4.1 修复文章内容消失的问题 106 | // @note 20-06-04 2.4.0 修复推荐按钮错位的问题 107 | // @note 20-06-04 2.3.9 窄屏适配优化 108 | // @note 20-06-04 2.3.8 黑夜模式出现问题,紧急回档到 2.3.6 109 | // @note 20-06-03 2.3.7 感谢 @AlexLWT 增加黑暗模式 110 | // @note 20-06-02 2.3.6 AdsByGoogle 删除 111 | // @note 20-05-25 2.3.5 感谢 @RyanIPO 修复 Cannot read property 'replace' of undefined 报错的问题 112 | // @note 20-05-24 2.3.4 修复免登录复制功能 113 | // @note 20-05-22 2.3.3 Logo与背景同步 114 | // @note 20-05-22 2.3.2 深度删除背景 115 | // @note 20-05-20 2.3.1 通过require使用NProgress 116 | // @note 20-05-20 2.3.0 显示推荐内容按钮样式内置,剔除CDN 117 | // @note 20-05-17 2.2.9 进度条样式更新,时间延时优化 118 | // @note 20-05-17 2.2.8 更新脚本描述,展开评论的所有回复,删除创作中心按钮,加载进度条 119 | // @note 20-05-17 2.2.7 更新脚本描述 120 | // @note 20-05-16 2.2.6 修复第一次点击显示推荐内容无反应的问题 121 | // @note 20-05-16 2.2.5 删除抢沙发角标,修改显示推荐内容按钮样式 122 | // @note 20-05-16 2.2.4 感谢来自GitHub的朋友“HeronZhang”的Issue建议,删除所有博客花里胡哨的背景,主页分类中广告清除,CSS样式控制宽度适配代码优化 123 | // @note 20-05-16 2.2.3 感谢来自GitHub的朋友“RetiredWorld”的代码贡献,使用CSS来控制样式,而不是JS,增大灵活性。 124 | // @note 20-05-13 2.2.2 屏蔽您的缩放不是100%的提示 125 | // @note 20-04-29 2.2.1 感谢大家的支持,增加目录显示,自动判断是否存在目录调整页面宽度,屏蔽新增广告,欢迎大家体验并提出意见! 126 | // @note 20-04-15 2.2.0 一些广告被其他插件屏蔽导致的异常无视之 127 | // @note 20-03-30 2.1.9 干掉“记录你的创作历程”,干掉未登录情况下的角标提醒 128 | // @note 20-03-13 2.1.8 窄屏适配加强 129 | // @note 20-03-13 2.1.7 更新简介 130 | // @note 20-03-12 2.1.6 宽度自适应(感谢来自GitHub的朋友LeonG7的建议)!修复剪贴板净化无效的问题。 131 | // @note 20-03-04 2.1.5 适配AdGuard 132 | // @note 20-02-27 2.1.4 优化免登录复制 133 | // @note 20-02-25 2.1.3 免登录复制更新,现已可用 134 | // @note 20-02-24 2.1.2 By Github@JalinWang 更改去除剪贴板劫持的方式,使得原文格式在复制时能够保留 135 | // @note 20-02-22 2.1.1 紧急修复由于 CSDN 修改前端结构导致的文章错位 136 | // @note 20-02-11 2.1.0 若干动画优化,视觉体验更流畅 137 | // @note 20-02-06 2.0.9 武汉加油!修改推荐内容切换开关位置,减少违和感 138 | // @note 20-01-17 2.0.8 去除右侧广告 139 | // @note 20-01-17 2.0.7 感谢来自GitHub的朋友“gleans”的建议,去掉页头广告 140 | // @note 19-12-12 2.0.6 感谢来自GitHub的朋友“yexuesong”的建议,将作者信息在文章顶部展示 141 | // @note 19-10-30 2.0.5 美化隐藏按钮,增加点击动画 142 | // @note 19-10-30 2.0.4 删除CSDN官方在主页推送的文章(大多是广告) 143 | // @note 19-10-30 2.0.3 添加更多屏蔽脚本 144 | // @note 19-10-30 2.0.0 祝自己生日快乐~完全重写CSDNGreener,统一使用JQuery,效率更高 145 | // @note 19-10-27 1.5.2 删除分享海报提示&&感谢GitHub的朋友“CHN-STUDENT”的反馈,去除底部课程推荐 146 | // @note 19-10-27 1.5.1 感谢来自GitHub的朋友“CHN-STUDENT”的细致复现反馈,去除了底部的课程推荐广告 147 | // @note 19-10-04 1.5.0 移除了底部主题信息和打赏 148 | // @note 19-09-10 1.4.9 感谢来自GitHub的朋友“programmerZe”的细致复现反馈,修复了评论区点击查看回复后,已经展开的评论会收起的问题 149 | // @note 19-09-04 1.4.8 感谢来自GitHub的朋友“dwdcth”的细致复现反馈,现在查看原创文章不会无限弹登录窗口了,且加强了自动展开功能 150 | // @note 19-08-20 1.4.7 感谢油叉用户“SupremeSir”的反馈,修复了右侧悬浮栏遮挡文章的问题 151 | // @note 19-08-14 1.4.6 无语。刚更新的免登录复制,又改了。修复! 152 | // @note 19-08-13 1.4.5 更新了独家功能:免登录复制 153 | // @note 19-08-13 1.4.4 感谢来自GitHub的朋友“iamsunxing”的反馈,修复了顶部不贴边的问题 154 | // @note 19-08-01 1.4.3 感谢油叉用户“ddddy”的反馈,去除了更多推广广告 155 | // @note 19-07-30 1.4.2 感谢油叉用户“周义杰”的反馈,增加了防CSDN外链重定向的功能(CSDN臭流氓) 156 | // @note 19-07-20 1.4.1 修复了推荐内容开关跨文章无效问题(忘了配置Cookie作用域) 157 | // @note 19-07-19 1.4.0 1. 构架大更新 2. 感谢来自GitHub的朋友"lukemin"的反馈,加入了下方推荐内容是否隐藏开关(实用) 158 | // @note 19-07-13 1.3.0 感谢来自GitHub的朋友“Holaplace”的反馈,修复了文章无法自动展开的问题(CSDN总改这个,令人头疼) 159 | // @note 19-06-08 1.2.6 感谢油叉用户“DeskyAki”的反馈,修复了文章无法自动展开的问题 160 | // @note 19-06-07 1.2.4 修复了登录后评论无法正常打开的问题 161 | // @note 19-06-07 1.2.3 感谢油叉用户"永远的殿下"的反馈,在一上午的努力攻克下,终于实现了未登录展开评论的语句 162 | // @note 19-06-05 1.2.0 修复了评论无法自动展开的BUG 163 | // @note 19-06-04 1.1.9 修复了无法自动展开的BUG(自闭了) 164 | // @note 19-06-04 1.1.6 CSDN太坏了,把“消息”按钮的Class设置成了“GitChat”,所以修复了“消息”按钮消失的问题 165 | // @note 19-06-04 1.1.5 1. 优化了论坛体验 2.美化、优化代码结构 166 | // @note 19-06-04 1.1.4 感谢来自GitHub的朋友“iamsunxing”的反馈,增加了论坛广告匹配规则 167 | // @note 19-06-03 1.1.3 感谢来自GitHub的朋友“wangwei135”的反馈,去除了评论区上方的广告 168 | // @note 19-05-27 1.1.2 感谢油叉用户“夏伟杰”的反馈,修复了富文本编辑器无法使用的问题 169 | // @note 19-05-25 1.1.0 1. 修复了主页广告的问题 2. 论坛自动展开 3. 论坛广告消除 170 | // @note 19-05-25 1.0.9 感谢油叉用户“渣渣不准说话”的反馈,修复了收藏按钮消失的问题 171 | // @note 19-03-01 1.0.3 添加页面选择性过滤规则 172 | // @note 19-03-01 1.0.2 增加了净化剪贴板功能 173 | // @note 19-03-01 1.0.1 修复了排版问题, 优化了代码结构 174 | // @note 19-02-26 1.0.0 初版发布 175 | // ==/UserScript== 176 | var version = "4.2.3"; 177 | var currentURL = window.location.href; 178 | if (currentURL.indexOf("?") !== -1) { 179 | currentURL = currentURL.substring(0, currentURL.indexOf("?")); 180 | } 181 | var list; 182 | var windowTop = 0; 183 | var startTimeMilli = Date.now(); 184 | var stopTimeMilli = 0; 185 | // 配置控制类 186 | class Config { 187 | get(key, value) { 188 | var cookie = $.cookie(key); 189 | if (cookie == undefined) { 190 | new Config().set(key, value); 191 | console.debug("Renew key: " + key + " : " + value); 192 | return value; 193 | } 194 | console.debug("Read key: " + key + " : " + cookie); 195 | if (cookie === "true") { return true; } 196 | if (cookie === "false") { return false; } 197 | return cookie; 198 | } 199 | 200 | getS(key, value) { 201 | var cookie = $.cookie(key); 202 | if (cookie == undefined) { 203 | new Config().set(key, value); 204 | console.debug("Renew key: " + key + " : " + value); 205 | return value; 206 | } 207 | console.debug("Read key: " + key + " : " + cookie); 208 | return cookie; 209 | } 210 | 211 | set(setKey, setValue) { 212 | $.cookie(setKey, setValue, { 213 | path: '/', 214 | expires: 365 215 | }); 216 | console.debug("Key set: " + setKey + " : " + setValue); 217 | } 218 | 219 | listenButton(element, listenKey, trueAction, falseAction) { 220 | $(element).click(function () { 221 | let status = new Config().get(listenKey, true); 222 | console.debug("Status: " + status); 223 | if (status === "true" || status) { 224 | console.debug("Key set: " + listenKey + " :: " + false); 225 | new Config().set(listenKey, false); 226 | } else { 227 | console.debug("Key set: " + listenKey + " :: " + true); 228 | new Config().set(listenKey, true); 229 | } 230 | }); 231 | } 232 | 233 | listenButtonAndAction(element, listenKey, trueAction, falseAction) { 234 | $(element).click(function () { 235 | let status = new Config().get(listenKey, true); 236 | console.debug("Status: " + status); 237 | if (status === "true" || status) { 238 | console.debug("Key set: " + listenKey + " :: " + false); 239 | new Config().set(listenKey, false); 240 | falseAction(); 241 | } else { 242 | console.debug("Key set: " + listenKey + " :: " + true); 243 | new Config().set(listenKey, true); 244 | trueAction(); 245 | } 246 | }); 247 | } 248 | } 249 | var config = new Config(); 250 | var progress = 0; 251 | class Progress { 252 | init() { 253 | progress = 0; 254 | NProgress.start(); 255 | $("#greenerProgress").text("绿化中..."); 256 | $(".toolbar-search").hide(); 257 | } 258 | 259 | setProgress(p) { 260 | progress = p; 261 | $("#greenerProgress").text(progress + "%"); 262 | NProgress.set(progress / 100); 263 | console.log(progress + "%"); 264 | } 265 | 266 | incProgress(p) { 267 | progress = progress + p; 268 | progress = progress > 100 ? 100 : progress; 269 | $("#greenerProgress").text(progress + "%"); 270 | NProgress.set(progress / 100); 271 | console.log(progress + "%"); 272 | } 273 | 274 | done() { 275 | progress = 100; 276 | NProgress.done(); 277 | $("#greenerProgress").html(protect_svg + ' CSDNGreener 正在守护您的浏览体验'); 278 | setTimeout(function() { 279 | $("#greenerProgress").fadeOut(500); 280 | setTimeout(function() { 281 | $(".toolbar-search").fadeIn(500); 282 | if (!isFirefox()) { 283 | // 提示 284 | let tipsCookie = config.get("showTip", true); 285 | if (tipsCookie) { 286 | showTips(); 287 | } 288 | config.set("showTip", false); 289 | } 290 | }, 500); 291 | }, 1500); 292 | } 293 | } 294 | var progressor = new Progress(); 295 | 296 | // 自定义 CSS 297 | // 进度条 298 | $('head').append(""); 299 | // 设置窗口 300 | $('head').append(""); 301 | // 提示条 302 | $('head').append(""); 303 | // 按钮(旧) 304 | $('head').append(""); 305 | // 保存按钮 306 | $('head').append(""); 307 | // Star 样式 308 | $('head').append(""); 309 | // 设置窗口文字效果 310 | if (isFirefox()) { 311 | $('head').append(""); 312 | } else { 313 | $('head').append(""); 314 | } 315 | // SVG 316 | //var save_svg = ''; 317 | var star_svg_1 = ''; 318 | var star_svg_2 = ' '; 319 | var star_svg_3 = ' '; 320 | var star_svg_4 = ' '; 321 | var star_svg = star_svg_1 + star_svg_2 + star_svg_3 + star_svg_4; 322 | var donate_svg = ''; 323 | var set_svg = ''; 324 | var save_svg = ''; 325 | var settings_svg = ''; 326 | var protect_svg = ''; 327 | 328 | // jquery.showtips.js 329 | (function(jQuery) { 330 | jQuery.fn.showTips = function(options,elem){ 331 | var config = { 332 | skin:"trips", 333 | content:$(this).attr("tips")||"弹出类型的气泡提示!", //气泡提示内容里面可以是HTML,默认显示自定义的提示内容 334 | width:"auto", //默认为auto,可以写具体尺寸如:200 335 | alignTo:["right","center"], //箭头方向 336 | color:["rgb(247, 206, 57)","#FFFEF4"], //这里是提示层的风格,第一个参数为提示边框颜色,第二个参数为提示背景颜色 337 | type:"html", //显示内容类型 338 | trigger:"click", //默认为点击显示,show为初始化就显示,hover为经过显示,focus焦点显示,mouse跟随鼠标显示隐藏 339 | spacing:10, //默认为箭头距离对象的尺寸 340 | customid:"", //自定义ID 341 | isclose:false, //是否显示关闭按钮 342 | success : null //成功后的回调函数 343 | }; 344 | var opts = jQuery.extend(config, options); 345 | return this.each(function(){ 346 | var that = jQuery(this),tipBox,tipId,selfH,selfW,conId,docW, spa = opts.spacing, skin=opts.skin; 347 | var Mathrandom = Math.floor(Math.random() * 9999999); 348 | var pmr = (opts.customid=="") ? Mathrandom :opts.customid.replace(/[#.]/, ""); 349 | var pointer=opts.alignTo.length===1 ? ''+opts.alignTo[0]+'' : ''+opts.alignTo[0]+'-'+opts.alignTo[1]+''; 350 | 351 | if(typeof elem == 'string') { 352 | if(elem =="show"){ 353 | jQuery('#tip'+pmr).show(); jQuery("#con"+pmr).html(opts.content); 354 | showPosition(pointer,jQuery('#tip'+pmr)); 355 | }; 356 | if(elem =="hide"){jQuery('#tip'+pmr).hide()}; 357 | }; 358 | if(typeof elem == '' || typeof elem == undefined){return true}; 359 | if(jQuery('#tip'+pmr).length==1){return false;} 360 | tipBox=jQuery('
').appendTo(document.body); 361 | tipId = jQuery("#tip"+pmr); 362 | conId = jQuery("#con"+pmr); 363 | 364 | var edgecolor='border-'+opts.alignTo[0]+'-color', tfi=tipId.find("i"), tfem=tipId.find("em"), tfiem=tipId.find("i,em"); 365 | tipId.css({'position':'absolute',border:'1px solid','border-color':opts.color[0],'background-color':opts.color[1]}); 366 | if(opts.alignTo[1]=='center'){ var offpos=50,percen="%"; }else{ var offpos=5,percen="px"; }; 367 | tfiem.css({width:0,height:0,content:'','position':'absolute'}) 368 | tfi.css({border:'8px solid transparent','z-index':5}); 369 | tfem.css({border:'7px solid transparent','z-index':10}); 370 | switch (pointer) { 371 | case 'top-center': 372 | case 'bottom-center': 373 | case 'top-left': 374 | case 'bottom-left': 375 | var poi="left"; 376 | if(pointer=='top-center' || pointer=='bottom-center'){ 377 | tfi.css({"margin-left":"-8px"}); 378 | tfem.css({"margin-left":"-7px"}); 379 | } 380 | break; 381 | case 'left-center': 382 | case 'right-center': 383 | case 'left-top': 384 | case 'right-top': 385 | var poi="top"; 386 | if(pointer=='left-center' || pointer=='right-center'){ 387 | tfi.css({"margin-top":"-8px"}); 388 | tfem.css({"margin-top":"-7px"}); 389 | } 390 | break; 391 | default: 392 | var poi="right"; 393 | break; 394 | }; 395 | 396 | if(pointer=='follow'){ 397 | tfi.css({'border-bottom-color':opts.color[0],left:''+offpos+percen+'',bottom:'100%'}); 398 | tfem.css({'border-bottom-color':opts.color[1],left:''+(offpos+(opts.alignTo[1]=='center'?0:1))+percen+'',bottom:'100%'}); 399 | }else{ 400 | tfi.css(edgecolor,opts.color[0]).css(poi,''+offpos+percen+''); 401 | tfem.css(edgecolor,opts.color[1]).css(poi,''+(offpos+(opts.alignTo[1]=='center'?0:1))+percen+''); 402 | tfiem.css(opts.alignTo[0],'100%'); 403 | }; 404 | 405 | switch (opts.type) { 406 | case 'html':conId.html(opts.content); break; 407 | case 'id' : 408 | var tempid=jQuery(opts.content) ,wrap = document.createElement("div"); 409 | if(tempid.css("display") == "none"){ tempid.css({display:"block"}); } 410 | conId.append(tempid); 411 | break; 412 | }; 413 | if(opts.isclose){ 414 | jQuery('×').appendTo(tipId); 415 | tipId.find("#close"+pmr+"").on("click",function(){tipId.hide();}); 416 | } 417 | 418 | if(typeof opts.width === 'string'){ 419 | docW = parseInt(document.body.clientWidth*(opts.width.replace('%','')/100)); 420 | (typeof opts.width == 'auto' || typeof opts.width == '') ? tipBox.css({width:'auto'}) : tipBox.css({width:docW}); 421 | tipBox.height(); 422 | }else{ 423 | tipBox.width(opts.width).height(); 424 | } 425 | function showPosition(pointer,cell){ 426 | var selfH = that.outerHeight(true), selfW = that.outerWidth(true); 427 | var post=that.offset().top, posl=that.offset().left; 428 | var tipCell=(cell=="" || cell==undefined) ? tipId : cell; 429 | var tipH=tipCell.outerHeight(true), tipW=tipCell.outerWidth(true); 430 | 431 | switch (pointer) { 432 | case 'top-left': tipCell.css({top:post-tipH-spa,left:posl}); break; 433 | case 'top-center': tipCell.css({top:post-tipH-spa,left:posl-(tipW/2)+(selfW/2)}); break; 434 | case 'top-right': tipCell.css({top:post-tipH-spa,left:posl-(tipW-selfW)}); break; 435 | case 'bottom-left': tipCell.css({top:post+selfH+spa,left:posl}); break; 436 | case 'bottom-center': tipCell.css({top:post+selfH+spa,left:posl-(tipW/2)+(selfW/2)}); break; 437 | case 'bottom-right': tipCell.css({top:post+selfH+spa,left:posl-(tipW-selfW)}); break; 438 | case 'left-top': tipCell.css({top:post,left:posl-tipW-spa}); break; 439 | case 'left-center': tipCell.css({top:post-(tipH/2)+(selfH/2),left:posl-tipW-spa}); break; 440 | case 'right-top': tipCell.css({top:post,left:posl+selfW+spa}); break; 441 | case 'right-center': tipCell.css({top:post-(tipH/2)+(selfH/2),left:posl+selfW+spa}); break; 442 | case 'follow': that.mousemove(function(e) { tipCell.css({top:e.pageY + 30,left:e.pageX - 6}); }); break; 443 | }; 444 | } 445 | tipBox.hide(); 446 | switch (opts.trigger){ 447 | case 'show':showPosition(pointer);tipBox.show();break; 448 | case 'click':that.click(function(){showPosition(pointer);tipBox.show();});break; 449 | case 'hover':that.hover(function(){showPosition(pointer);tipBox.show(); tipBox.on("mouseover",function(){jQuery(this).show()}).on("mouseout",function(){jQuery(this).hide()})},function(){tipBox.hide();});break; 450 | case 'focus':that.focus(function(){showPosition(pointer);tipBox.show();}); that.blur(function(){tipBox.hide();});break; 451 | case 'mouse':that.hover(function(){showPosition(pointer);tipBox.show();},function(){tipBox.hide();});break; 452 | }; 453 | setTimeout(function(){opts.success && opts.success();}, 1); 454 | }); 455 | } 456 | })(jQuery); 457 | 458 | (function () { 459 | 'use strict'; 460 | 461 | l("CSDNGreener V" + version); 462 | if (isFirefox()) { 463 | console.log("您正在使用火狐浏览器,将使用兼容模式运行 CSDNGreener。"); 464 | } 465 | progressor.init(); 466 | 467 | // 绿化设定按钮点击事件 468 | let jss = ""; 469 | jss += ""; 476 | $("body").append(jss); 477 | 478 | // 保存按钮点击事件 479 | let saveJss = ""; 480 | saveJss += ""; 484 | $("body").append(saveJss); 485 | 486 | setTimeout(function() { 487 | var blockURL = currentURL.split("/").length; 488 | var main = /(www\.csdn\.net\/)$/; 489 | var mainNav = /nav/; 490 | var article = /article/; 491 | var bbs = /bbs\.csdn\.net/; 492 | var blog = /blog\.csdn\.net/; 493 | var blog2 = /\/article\/list\//; 494 | var download = /download\.csdn\.net/; 495 | var login = /passport\.csdn\.net/; 496 | var zone = /me\.csdn\.net/; 497 | var other = /(www\.csdn\.net\/)/; 498 | var mp = /mp\.csdn\.net/; 499 | var article_month = /article\/month/; 500 | var link = /link\.csdn\.net/; 501 | var blink = /blink\.csdn\.net/; 502 | 503 | // 数组初始化 504 | list = []; 505 | // 头部分 506 | // APP 507 | // put(".app-app"); 508 | // VIP 509 | put(".vip-caise"); 510 | // 记录你的成长历程(记个毛) 511 | put("#writeGuide"); 512 | // 新通知小圆点(未登录才消掉) 513 | if ($(".userinfo a").text() === '登录/注册') { 514 | put("#msg-circle"); 515 | } 516 | // 顶部谷歌广告 517 | put(".adsbygoogle"); 518 | // 悬浮在顶栏按钮上出现的二维码 519 | put(".appControl"); 520 | // 顶部广告 521 | put(".advert-bg"); 522 | 523 | if (main.test(currentURL) || mainNav.test(currentURL)) { 524 | l("正在优化主页体验..."); 525 | // 常规 526 | // 头部广告 527 | put(".banner-ad-box"); 528 | // 嵌入广告 529 | put("#kp_box_211"); 530 | // 右侧广告 531 | put(".slide-outer"); 532 | // 右侧详情 533 | put(".persion_article"); 534 | // 右侧推荐 535 | $(".feed_company").parent().remove(); 536 | // 广告轮播 537 | put(".el-carousel__container"); 538 | // 顶部横幅 539 | put(".toolbar-advert"); 540 | // 顶栏VIP选项 541 | $('.toolbar-subMenu-box').find("[href='https://mall.csdn.net/vip']").parent().remove(); 542 | // CSDN工具广告 543 | put("#floor-ad_64"); 544 | clean(10); 545 | // common(5, 10); 546 | // 博客及主页优化 547 | common(9, 10); 548 | loop(3); 549 | loop(1); 550 | } else if ((blog.test(currentURL) && blockURL === 4) || blog2.test(currentURL)) { 551 | l("正在优化个人博客主页体验..."); 552 | // 常规 553 | // 头部广告 554 | put(".banner-ad-box"); 555 | // 右侧广告 556 | put(".slide-outer"); 557 | // 右侧详情 558 | put(".persion_article"); 559 | // 左侧广告 560 | put(".mb8"); 561 | put("#kp_box_503"); 562 | put("#kp_box_214"); 563 | clean(10); 564 | // common(5, 10); 565 | loop(3); 566 | loop(1); 567 | } else if (article.test(currentURL) && !mp.test(currentURL) && !article_month.test(currentURL)) { 568 | l("正在优化阅读体验..."); 569 | // 绿化设定 570 | if (isFirefox()) { 571 | setTimeout(function() { 572 | $(".toolbar-container-middle").prepend("
"); 573 | let htmlOf0 = '
' + settings_svg + '
'; 574 | $(".toolbar-btns").prepend(htmlOf0); 575 | if (isFirefox()) { 576 | // 提示 577 | let tipsCookie = config.get("showTip", true); 578 | if (tipsCookie) { 579 | showTips(); 580 | } 581 | config.set("showTip", false); 582 | } 583 | }, 3000); 584 | } else { 585 | $(".toolbar-container-middle").prepend("
"); 586 | let htmlOf0 = '
' + settings_svg + '
'; 587 | $(".toolbar-btns").prepend(htmlOf0); 588 | } 589 | // 常规 590 | // 右侧广告,放到第一个清除 591 | // put(".recommend-right"); 592 | put("#addAdBox"); 593 | // put(".aside-box.kind_person.d-flex.flex-column"); 594 | put(".recommend-top-adbox"); 595 | // put(".recommend-list-box.d-flex.flex-column.aside-box"); 596 | // 左侧广告 597 | // put("#container"); 598 | // 快来写博客吧 599 | put(".blog_tip_box"); 600 | // 推荐关注用户 601 | put(".blog-expert-recommend-box"); 602 | // 右下角VIP 603 | put(".meau-gotop-box"); 604 | // 广告 605 | put(".mediav_ad"); 606 | put(".pulllog-box"); 607 | put(".recommend-ad-box"); 608 | put(".box-shadow"); 609 | put(".type_hot_word"); 610 | put(".fourth_column"); 611 | // 高分辨率时右侧文章推荐 612 | // put(".right-item"); 613 | // 广告 614 | put("#asideFooter"); 615 | put("#ad-div"); 616 | put("#479"); 617 | put("#480"); 618 | // 打赏 619 | put(".postTime"); 620 | // 课程推荐 621 | put(".t0"); 622 | // 分享海报 623 | put(".shareSuggest"); 624 | // 底部主题 625 | put(".template-box"); 626 | // 评论区广告 627 | put("div#dmp_ad_58"); 628 | // 打赏 629 | put(".reward-user-box"); 630 | // 右侧打赏按钮 631 | put(".to-reward"); 632 | // 推荐内容广告 633 | put(".recommend-recommend-box"); 634 | // 右侧广告 635 | put(".indexSuperise"); 636 | // 抢沙发角标 637 | put(".comment-sofa-flag"); 638 | // 页jio 639 | put(".bottom-pub-footer"); 640 | // 登录查看未读消息 641 | put(".toolbar-notice-bubble"); 642 | // 右侧广告 643 | put(".recommend-top-adbox"); 644 | // 右侧四个广告 645 | put(".programmer1Box"); 646 | put(".programmer2Box"); 647 | put(".programmer3Box"); 648 | put(".programmer4Box"); 649 | // 点赞气泡 650 | put(".triplet-prompt"); 651 | // 顶部横幅 652 | put(".toolbar-advert"); 653 | // 底部信息 654 | put(".blog-footer-bottom"); 655 | // 右侧栏广告 656 | put("#6527"); 657 | put("#recommendAdBox"); 658 | // 推荐内容Title 659 | put(".recommend-tit-mod"); 660 | // 红包提醒 661 | put(".csdn-redpack-lottery-btn-box"); 662 | // 学生认证 663 | put(".csdn-highschool-window"); 664 | // 右侧悬浮栏除置顶以外的按钮 665 | put(".option-box[data-type='guide'],.option-box[data-type='cs'],.csdn-common-logo-advert"); 666 | // 登录后您可以享受以下权益 667 | put(".passport-login-tip-container"); 668 | // 底栏“觉得还不错?立即收藏”你在教我做事? 669 | put(".tool-active-list"); 670 | // 文章底部 archive推荐 671 | put("#treeSkill"); 672 | // 搜索框fire emoji 673 | put(".icon-fire"); 674 | clean(10); 675 | setTimeout(function() { 676 | // 展开评论的所有回复 677 | $('.btn-read-reply').click(); 678 | // 右侧toolbar 创作提示 679 | $(".sidetool-writeguide-box").remove(); 680 | }, 1500); 681 | // 主动加入右侧栏 682 | if ($(".recommend-right").length === 0) { 683 | $("#mainBox").after('
'); 684 | } 685 | // 上栏按钮删除 686 | $(".toolbar-menus > li > a:contains('专栏课程')").parent().remove(); 687 | $(".toolbar-menus > li > a:contains('插件')").parent().remove(); 688 | $(".toolbar-menus > li > a:contains('认证')").parent().remove(); 689 | // 修复无法选择复制 690 | $("code").css("user-select","auto"); 691 | $("#content_views").css("user-select","auto"); 692 | $("pre").css("user-select","auto");7 693 | // 图片混文字时,无法完整复制,图片不会被复制下来 https://github.com/adlered/CSDNGreener/issues/87 694 | //let el = $("main .blog-content-box")[0]; 695 | //let elClone = el.cloneNode(true); 696 | //el.parentNode.replaceChild(elClone, el); 697 | // 保存csdn的网页再次打开会自动跳转到首页 https://github.com/adlered/CSDNGreener/issues/97 698 | $("[onerror]").remove(); 699 | // CSDN重定向外链不能在新的窗口跳转 https://github.com/adlered/CSDNGreener/issues/80 700 | $("#article_content a[href]").attr("target", "_blank"); 701 | // 搜索框优化 702 | //$("#toolbar-search-input").css("width", "calc(100% - 400px)"); 703 | // 取消代码折叠 704 | $(".look-more-preCode").click(); 705 | // 询问推荐是否有意义的问卷调查 706 | $("#recommendNps").remove(); 707 | // 绿化设置 708 | common(6, 1); 709 | // 屏幕适配 710 | common(4, 1); 711 | // 评论 712 | common(1, 30); 713 | // 其它 714 | common(2, 20); 715 | // 顶部显示作者信息 716 | common(8, 1); 717 | // 博客及主页优化 718 | common(9, 10); 719 | // 循环线程开始 720 | loop(2); 721 | loop(3); 722 | } else if (bbs.test(currentURL)) { 723 | l("正在优化论坛体验..."); 724 | // 常规 725 | // 评论嵌入小广告 726 | put(".post_recommend"); 727 | // 底部推荐 728 | put("#post_feed_wrap"); 729 | // 底部相关文章里面的广告 730 | put(".bbs_feed_ad_box"); 731 | put(".recommend-ad-box"); 732 | // 底部相关文字里面的热词提示 733 | put(".type_hot_word"); 734 | // 底部蓝色flex属性的广告栏+登录注册框 735 | put(".pulllog-box"); 736 | // 猜你喜欢 737 | put(".personalized-recommend-box"); 738 | // 发帖减半提示 739 | put(".totast-box"); 740 | // 顶部广告 741 | put(".recommend-right"); 742 | // 顶部广告 743 | put(".ad_top"); 744 | // 右侧广告 745 | put(".ad_1"); 746 | clean(10); 747 | // 展开 748 | common(3, 50); 749 | // common(5, 10); 750 | loop(3); 751 | } else if (download.test(currentURL)) { 752 | l("正在优化下载页体验..."); 753 | // 常规 754 | put(".fixed_dl"); 755 | put("indexSuperise"); 756 | // 右侧推荐 757 | put(".content_recom"); 758 | clean(10); 759 | // common(5, 10); 760 | loop(3); 761 | } else if (login.test(currentURL)) { 762 | l("正在优化登录页体验..."); 763 | // 常规 764 | // 登录界面大图广告 765 | put(".main-tu"); 766 | clean(10); 767 | // common(5, 10); 768 | loop(3); 769 | } else if (zone.test(currentURL)) { 770 | l("正在优化个人空间体验..."); 771 | // 常规 772 | clean(10); 773 | common(7, 10); 774 | // common(5, 10); 775 | loop(3); 776 | } else if (blink.test(currentURL)) { 777 | l("正在优化个人动态体验..."); 778 | } else if (link.test(currentURL)) { 779 | // 跳过 CSDN 的 link 页面 780 | var url = new URL(window.location.href) 781 | var target = url.searchParams.get('target') 782 | window.location.href = target 783 | } else { 784 | l("哦豁,好偏门的页面,我来试着优化一下哦..."); 785 | // 常规 786 | // 展开全文 787 | $('.readmore_btn').click(); 788 | // *** index *** 789 | // 头部广告 790 | put(".banner-ad-box"); 791 | // 嵌入广告 792 | put("#kp_box_211"); 793 | // 右侧广告 794 | put(".slide-outer"); 795 | // 右侧详情 796 | put(".persion_article"); 797 | // 右侧推荐 798 | $(".feed_company").parent().remove(); 799 | // *** article *** 800 | // 常规 801 | // 右侧广告,放到第一个清除 802 | put("#addAdBox"); 803 | put(".recommend-top-adbox"); 804 | // 快来写博客吧 805 | put(".blog_tip_box"); 806 | // 推荐关注用户 807 | put(".blog-expert-recommend-box"); 808 | // 右下角VIP 809 | put(".meau-gotop-box"); 810 | // 广告 811 | put(".mediav_ad"); 812 | put(".pulllog-box"); 813 | put(".recommend-ad-box"); 814 | //put(".box-shadow"); 某些页面异常,例如cloud.csdn.net 815 | put(".type_hot_word"); 816 | put(".fourth_column"); 817 | // cloud.csdn.net 头部广告 818 | put("#kp_box_118"); 819 | // 广告 820 | put("#asideFooter"); 821 | put("#ad-div"); 822 | put("#479"); 823 | put("#480"); 824 | // 打赏 825 | put(".postTime"); 826 | // 课程推荐 827 | put(".t0"); 828 | // 分享海报 829 | put(".shareSuggest"); 830 | // 底部主题 831 | put(".template-box"); 832 | // 评论区广告 833 | put("div#dmp_ad_58"); 834 | // 打赏 835 | put(".reward-user-box"); 836 | // 右侧打赏按钮 837 | put(".to-reward"); 838 | // 推荐内容广告 839 | put(".recommend-recommend-box"); 840 | // 右侧广告 841 | put(".indexSuperise"); 842 | // 抢沙发角标 843 | put(".comment-sofa-flag"); 844 | // 页jio 845 | put(".bottom-pub-footer"); 846 | // 登录查看未读消息 847 | put(".toolbar-notice-bubble"); 848 | // 右侧广告 849 | put(".recommend-top-adbox"); 850 | // 学院弹出广告 851 | $(".fouce_close_btn").click(); 852 | // 其它 853 | // 头部广告 854 | put(".banner-ad-box"); 855 | // 右侧广告 856 | put(".slide-outer"); 857 | // 右侧详情 858 | put(".persion_article"); 859 | // 左侧广告 860 | put("#kp_box_503"); 861 | put("#kp_box_214"); 862 | // *** bbs *** 863 | // 评论嵌入小广告 864 | put(".post_recommend"); 865 | // 底部推荐 866 | put("#post_feed_wrap"); 867 | // 底部相关文章里面的广告 868 | put(".bbs_feed_ad_box"); 869 | put(".recommend-ad-box"); 870 | // 底部相关文字里面的热词提示 871 | put(".type_hot_word"); 872 | // 底部蓝色flex属性的广告栏+登录注册框 873 | put(".pulllog-box"); 874 | // 猜你喜欢 875 | put(".personalized-recommend-box"); 876 | // 发帖减半提示 877 | put(".totast-box"); 878 | // 顶部广告 879 | put(".recommend-right"); 880 | // 顶部广告 881 | put(".ad_top"); 882 | // *** download *** 883 | put(".fixed_dl"); 884 | put("indexSuperise"); 885 | // 右侧推荐 886 | put(".content_recom"); 887 | clean(10); 888 | } 889 | setTimeout(function() { 890 | progressor.done(); 891 | }, 0); 892 | stopTimeMilli = Date.now(); 893 | l("优化完毕! 耗时 " + (stopTimeMilli - startTimeMilli) + "ms"); 894 | }, 0); 895 | })(); 896 | 897 | function l(log) { 898 | console.log("[CSDNGreener] " + log); 899 | } 900 | 901 | function e(error) { 902 | console.error("[CSDNGreener] " + error); 903 | } 904 | 905 | function clear() { 906 | list = []; 907 | } 908 | 909 | function put(tag) { 910 | list.push(tag); 911 | } 912 | 913 | function clean(times) { 914 | var loop = setInterval(function () { 915 | --times; 916 | if (times <= 0) { 917 | clearInterval(loop); 918 | } 919 | for (var k = 0; k < list.length; k++) { 920 | $(list[k]).remove(); 921 | } 922 | }, 100); 923 | progressor.incProgress(10); 924 | } 925 | 926 | var deletedLogin = false; 927 | 928 | function loop(num) { 929 | setInterval(function () { 930 | if (num === 1) { 931 | // 主页中间的广告 932 | $(".J_adv").remove(); 933 | // 主页有新的内容横条 934 | $(".feed-fix-box").remove(); 935 | // 主页广告 iframe 936 | if (currentURL == "https://www.csdn.net/") { 937 | $("iframe").remove(); 938 | } 939 | // 删除 CSDN 官方在主页的文章(大多是广告) 940 | $("li.clearfix").each(function(index, ele) { 941 | var banned = /csdn<\/a>/; 942 | var aMark = $(ele).find(".name").html(); 943 | if (banned.test(aMark)) { 944 | $(ele).remove(); 945 | } 946 | }); 947 | // 主页广告 948 | $("li").each(function(){ 949 | let self = $(this); 950 | let dataType = self.attr('data-type'); 951 | if (dataType === 'ad') { 952 | self.remove(); 953 | } 954 | }); 955 | // 主页广告 956 | $("li > div > div > h2 > a[href*='https://edu.csdn.net']").parent().parent().parent().parent().remove(); 957 | $("li > div > div > h2 > a[href*='https://marketing.csdn.net']").parent().parent().parent().parent().remove(); 958 | // 官方脚本横幅 959 | $(".toolbar-advert").remove(); 960 | } else if (num === 2) { 961 | // 评论查看更多展开监听 962 | $("div.comment-list-box").css("max-height", "none"); 963 | // 屏蔽您的缩放不是100%的提示 964 | $('.leftPop').remove(); 965 | // 官方脚本横幅 966 | $(".toolbar-advert").remove(); 967 | } else if (num == 3) { 968 | // 循环删除登录提示框 969 | if ($($(".passport-login-container")[0]).length == 1 && deletedLogin == false) { 970 | let passInterval = setInterval(function() { 971 | $('.passport-login-container').hide(); 972 | console.log("hide"); 973 | }, 10); 974 | setTimeout(function() { 975 | clearInterval(passInterval); 976 | setTimeout(function() { 977 | $("#passportbox").find("img").click(); 978 | }, 500) 979 | }, 5000); 980 | deletedLogin = true; 981 | } 982 | // 红包雨 983 | $("#csdn-redpack").remove(); 984 | } 985 | }, 500); 986 | } 987 | 988 | function common(num, times) { 989 | var loop = setInterval(function () { 990 | --times; 991 | if (times <= 0) { 992 | clearInterval(loop); 993 | } 994 | if (num === 1) { 995 | // 查看更多 996 | $(".btn-readmore").removeClass("no-login"); 997 | $(".btn-readmore").addClass("fans-read-more"); 998 | $(".btn-readmore").removeAttr("href"); 999 | $(".btn-readmore").removeAttr("target"); 1000 | $(".btn-readmore").removeAttr("rel"); 1001 | $(".btn-readmore").click(); 1002 | // 已登录用户展开评论 1003 | try { 1004 | document.getElementById("btnMoreComment").click(); 1005 | } catch (e) {} 1006 | // 删除查看更多按钮 1007 | $("#btnMoreComment").parent("div.opt-box").remove(); 1008 | // 展开内容 1009 | $("div.comment-list-box").css("max-height", "none"); 1010 | // 改回背景颜色 1011 | $(".login-mark").remove(); 1012 | // 删除登录框 1013 | $(".login-box").remove(); 1014 | } else if (num === 2) { 1015 | // 挡住评论的“出头推荐” 1016 | if ($(".recommend-box").length > 1) { 1017 | $(".recommend-box")[0].remove(); 1018 | } 1019 | // 去除推广广告 1020 | $("li[data-type='ad']").remove(); 1021 | // 免登录复制 1022 | $(".hljs-button").removeClass("signin"); 1023 | $(".hljs-button").addClass("{2}"); 1024 | $(".hljs-button").attr("data-title", "免登录复制"); 1025 | $(".hljs-button").attr("onclick", "hljs.copyCode(event);setTimeout(function(){$('.hljs-button').attr('data-title', '免登录复制');},3500);"); 1026 | $("#content_views").unbind("copy"); 1027 | // 去除剪贴板劫持 1028 | $("code").attr("onclick", "mdcp.copyCode(event)"); 1029 | try { 1030 | // 复制时保留原文格式,参考 https://greasyfork.org/en/scripts/390502-csdnremovecopyright/code 1031 | Object.defineProperty(window, "articleType", { 1032 | value: 0, 1033 | writable: false, 1034 | configurable: false 1035 | }); 1036 | } catch (err) { 1037 | } 1038 | csdn.copyright.init("", "", ""); 1039 | // 页头广告 1040 | try { 1041 | document.getElementsByClassName("column-advert-box")[0].style.display="none"; 1042 | } catch (e) {} 1043 | // 自动检测是否有目录,如果没有则删除右边栏,文章居中 1044 | if ($(".recommend-right_aside").html() && $(".recommend-right_aside").html().replace(/[\r\n]/g, "").replace(/(\s)/g, "") === "") { 1045 | $("#rightAside").remove(); 1046 | } else if ($(".recommend-right_aside").html() && $("#recommend-right").html().replace(/[\r\n]/g, "").replace(/(\s)/g, "") === "") { 1047 | $("#rightAside").remove(); 1048 | } 1049 | // 登录按钮文字太多,修改 1050 | $("a").each(function() { 1051 | if ($(this).attr('href') === 'https://passport.csdn.net/account/login') { 1052 | $(this).html('登入'); 1053 | } 1054 | }); 1055 | // 顶栏广告 1056 | $("li").each(function(){ 1057 | let self = $(this); 1058 | let dataType = self.attr('data-sub-menu-type'); 1059 | if (dataType === 'vip') { 1060 | self.remove(); 1061 | } 1062 | let dataTitle = self.attr('title'); 1063 | if (dataTitle === '高价值源码课程分享' || dataTitle === '系统学习·问答·比赛' || dataTitle === '简单高效优惠的云服务') { 1064 | self.remove(); 1065 | } 1066 | }); 1067 | // 顶栏VIP选项 1068 | $('.toolbar-subMenu-box').find("[href='https://mall.csdn.net/vip']").parent().remove(); 1069 | } else if (num == 3) { 1070 | //论坛自动展开 1071 | $(".js_show_topic").click(); 1072 | } else if (num == 4) { 1073 | /** 配置控制 **/ 1074 | let config = new Config(); 1075 | let smCookie = config.get("scr-sm", true); 1076 | let mdCookie = config.get("scr-md", false); 1077 | let lgCookie = config.get("scr-lg", false); 1078 | let foCookie = config.get("scr-fo", false) 1079 | 1080 | $("#scr-sm").prop("checked", smCookie); 1081 | $("#scr-md").prop("checked", mdCookie); 1082 | $("#scr-lg").prop("checked", lgCookie); 1083 | $("#scr-fo").prop("checked", foCookie); 1084 | 1085 | if (smCookie) { 1086 | // Small Screen Mode 1087 | $(".main_father").removeClass("justify-content-center"); 1088 | GM_addStyle(` 1089 | main{ 1090 | width: auto!important; 1091 | float: none!important; 1092 | max-width: 90vw; 1093 | } 1094 | main article img{ 1095 | margin: 0 auto; 1096 | max-width: 100%; 1097 | object-fit: cover; 1098 | } 1099 | `); 1100 | $("#mainBox").css("width", "100%"); 1101 | } else if (mdCookie) { 1102 | // Middle Screen Mode 1103 | $(".main_father").removeClass("justify-content-center"); 1104 | } else if (lgCookie) { 1105 | // Large Screen Mode 1106 | $(".container").css("margin", "0 auto") 1107 | } else if (foCookie) { 1108 | // Focus mode 1109 | $(".recommend-right").remove(); 1110 | $(".container").css("width", "100%"); 1111 | $(".container > main").css("width", "100%"); 1112 | } 1113 | 1114 | // 屏幕尺寸单选监听 1115 | $("#scr-sm").click(function () { 1116 | new Config().set("scr-sm", true); 1117 | new Config().set("scr-md", false); 1118 | new Config().set("scr-lg", false); 1119 | new Config().set("scr-fo", false); 1120 | }); 1121 | $("#scr-md").click(function () { 1122 | new Config().set("scr-md", true); 1123 | new Config().set("scr-sm", false); 1124 | new Config().set("scr-lg", false); 1125 | new Config().set("scr-fo", false); 1126 | }); 1127 | $("#scr-lg").click(function () { 1128 | new Config().set("scr-lg", true); 1129 | new Config().set("scr-sm", false); 1130 | new Config().set("scr-md", false); 1131 | new Config().set("scr-fo", false); 1132 | }); 1133 | $("#scr-fo").click(function () { 1134 | new Config().set("scr-fo", true); 1135 | new Config().set("scr-sm", false); 1136 | new Config().set("scr-md", false); 1137 | new Config().set("scr-lg", false); 1138 | }); 1139 | // 判断是否为登录状态 1140 | if ($('.toolbar-btn-loginfun').text() === '登录') { 1141 | // 未登录删除无用按钮 1142 | $("a:contains('消息')").parent().parent()[0].remove(); 1143 | $(".toolbar-btn-collect").remove(); 1144 | $(".toolbar-btn-write").remove(); 1145 | $(".toolbar-btn-mp").remove(); 1146 | } 1147 | $("a:contains('会员12.12')").parent().remove(); 1148 | $(".toolbar-btn-vip").remove(); 1149 | } else if (num == 5) { 1150 | // 改回背景颜色 1151 | $(".login-mark").remove(); 1152 | // 删除登录框 1153 | $(".login-box").remove(); 1154 | } else if (num == 6) { 1155 | let did = false; 1156 | let configHTML = ''; 1157 | configHTML += '

CSDNGreener V' + version + ' ' + settings_svg + '

'; 1158 | configHTML += '

官方 QQ 交流群:1042370453


'; 1159 | 1160 | // 设定:推荐内容按钮 1161 | configHTML += '

根据屏幕尺寸,适配版式

建议逐个尝试后选择适合你的版式,屏幕过小或者版式选择不正确右侧栏可能没有空间显示,导致侧栏定制无效(请尝试调节浏览器缩放,快捷键 Ctrl+鼠标滚轮)。

'; 1162 | configHTML += ''; 1163 | configHTML += ''; 1164 | configHTML += ''; 1165 | configHTML += ''; 1166 | configHTML += '
'; 1167 | configHTML += '

通用设定

'; 1168 | configHTML += '

自定义背景图:

'; 1169 | configHTML += ' '; 1170 | configHTML += '
'; 1171 | configHTML += ' '; 1172 | configHTML += '
'; 1173 | configHTML += ' '; 1174 | configHTML += '
'; 1175 | configHTML += ' '; 1176 | configHTML += '
'; 1177 | configHTML += ' '; 1178 | configHTML += '
'; 1179 | configHTML += ' '; 1180 | configHTML += '
'; 1181 | configHTML += ' '; 1182 | configHTML += '
'; 1183 | configHTML += '
'; 1184 | configHTML += '

右侧栏定制

'; 1185 | configHTML += ' '; 1186 | configHTML += '
'; 1187 | configHTML += ' '; 1188 | configHTML += '
'; 1189 | configHTML += ' '; 1190 | configHTML += '
'; 1191 | configHTML += ' '; 1192 | configHTML += '
'; 1193 | configHTML += ' '; 1194 | configHTML += '
'; 1195 | configHTML += ' '; 1196 | configHTML += '
'; 1197 | configHTML += ' '; 1198 | configHTML += '
'; 1199 | configHTML += ' '; 1200 | configHTML += '
'; 1201 | configHTML += ' '; 1202 | configHTML += '
'; 1203 | configHTML += ' '; 1204 | configHTML += '

'; 1205 | configHTML += '
要不要来看看 :)

(作者本人建设的社区~

社区中聚集了同行业的大佬小白,欢迎小伙伴们一起摸鱼!

'; 1206 | configHTML += '
☕ 如果您觉得脚本好用,欢迎请我喝杯咖啡,我将努力更新脚本功能 ❤️
'; 1207 | configHTML += '' + star_svg + ' 点我~ 动动小手在 GitHub 点个 Star 和关注,支持我继续维护脚本 :)

'; 1208 | configHTML += '

特别提示:CSDNGreener 脚本不提供任何会员文章破解、会员资源下载功能,仅适用于前端优化,请在CSDN官方渠道购买CSDN会员体验付费功能。

'; 1209 | configHTML += '
'; 1210 | configHTML += '
'; 1211 | 1212 | // configHTML += '' + donate_svg + ' 我是老板,投币打赏'; 1213 | configHTML += '
'; 1214 | let saveButton = ''; 1215 | // 绿化器设定 1216 | $("body").after('
' + saveButton + configHTML); 1217 | 1218 | /** 配置控制 **/ 1219 | // 推荐内容 1220 | $(".blog-content-box").append("
"); 1221 | $("#recommendSwitch:last").append(' ' + 1222 | '

显示推荐内容

'); 1223 | let recommendCookie = config.get("recommend", false); 1224 | if (!recommendCookie) { 1225 | $(".recommend-box").hide(); 1226 | } 1227 | if (recommendCookie) { 1228 | $("#toggle-recommend-button").prop("checked", true); 1229 | $("#toggle-button").prop("checked", true); 1230 | } else { 1231 | $("#toggle-recommend-button").prop("checked", false); 1232 | $("#toggle-button").prop("checked", false); 1233 | } 1234 | config.listenButton("#toggle-recommend-button", "recommend", 1235 | function() {$(".recommend-box").slideDown(200);}, 1236 | function() {$(".recommend-box").slideUp(200);}); 1237 | config.listenButtonAndAction("#toggle-button", "recommend", 1238 | function() {$(".recommend-box").slideDown(200);}, 1239 | function() {$(".recommend-box").slideUp(200);}); 1240 | 1241 | // 显示小店 1242 | let shopCookie = config.get('shop',false); 1243 | if(!shopCookie){ 1244 | $("#csdn-shop-window").hide(); 1245 | $("#csdn-shop-window-top").hide(); 1246 | } 1247 | if (shopCookie) { 1248 | $("#toggle-shop-button").prop("checked", true); 1249 | } else { 1250 | $("#toggle-shop-button").prop("checked", false); 1251 | } 1252 | config.listenButton("#toggle-shop-button", "shop", 1253 | function() {location.reload();}, 1254 | function() {location.reload();}); 1255 | // 侧栏小广告 1256 | let adCookie = config.get("ad", true); 1257 | if (adCookie) { 1258 | setTimeout(function() { 1259 | // $("#recommend-right").append('

来自 CSDN 脚本的小广告

  • 您可在 脚本设置 中永久关闭小广告
    感谢您的支持 ❤️

    29元每月!CTGNet GIA 回程五网高端CN2 GIA/GT网络,支持VPC高级网络
    拒绝绕路,拒绝不稳定,助力企业拓展全球业务
    安全,稳定,高性能

'); 1260 | }, 500); 1261 | } 1262 | if (adCookie) { 1263 | $("#toggle-ad-button").prop("checked", true); 1264 | } else { 1265 | $("#toggle-ad-button").prop("checked", false); 1266 | } 1267 | config.listenButton("#toggle-ad-button", "ad", 1268 | function() {location.reload();}, 1269 | function() {location.reload();}); 1270 | // 显示作者名片 1271 | let authorCardCookie = config.get("authorCard", true); 1272 | if (authorCardCookie) { 1273 | // 博主信息 1274 | $('#recommend-right').append($('#asideProfile').prop("outerHTML")); 1275 | setTimeout(function() { 1276 | $('#asideProfile').attr("style", "margin-top: 8px; width: 300px;"); 1277 | }, 500); 1278 | } 1279 | if (authorCardCookie) { 1280 | $("#toggle-authorcard-button").prop("checked", true); 1281 | } else { 1282 | $("#toggle-authorcard-button").prop("checked", false); 1283 | } 1284 | config.listenButton("#toggle-authorcard-button", "authorCard", 1285 | function() {location.reload();}, 1286 | function() {location.reload();}); 1287 | 1288 | // 强制白色主题 1289 | let whiteThemeCookie = config.get("whiteTheme", false); 1290 | if (whiteThemeCookie) { 1291 | // 背景删除 1292 | $('.main_father').attr('style', 'background-image: none !important; background-color: #f5f6f7; background: #f5f6f7;'); 1293 | $('[href^="https://csdnimg.cn/release/phoenix/template/themes_skin/"]').attr('href', 'https://csdnimg.cn/release/phoenix/template/themes_skin/skin-technology/skin-technology-6336549557.min.css'); 1294 | $('#csdn-toolbar').removeClass('csdn-toolbar-skin-black'); 1295 | $('.csdn-logo').attr('src', '//csdnimg.cn/cdn/content-toolbar/csdn-logo.png?v=20200416.1'); 1296 | $('html').css('background-color', '#f5f6f7'); 1297 | } 1298 | if (whiteThemeCookie) { 1299 | $("#toggle-whitetheme-button").prop("checked", true); 1300 | } else { 1301 | $("#toggle-whitetheme-button").prop("checked", false); 1302 | } 1303 | config.listenButton("#toggle-whitetheme-button", "whiteTheme", 1304 | function() {location.reload();}, 1305 | function() {location.reload();}); 1306 | 1307 | // 背景图 1308 | let backgroundImage = GM_getValue("backgroundImage", ""); 1309 | if (backgroundImage !== "") { 1310 | $("#backgroundImgUrl").val(backgroundImage); 1311 | $(".main_father").attr('style', 'background-image:url(' + backgroundImage + ');background-attachment:fixed;background-size:100%;'); 1312 | } 1313 | $('#backgroundImgUrl').on('input', function() { 1314 | GM_setValue("backgroundImage", $("#backgroundImgUrl").val()); 1315 | }); 1316 | $('#backgroundImgUrl').on('change', function() { 1317 | GM_setValue("backgroundImage", $("#backgroundImgUrl").val()); 1318 | }); 1319 | $("#upload_bg").on('change', function() { 1320 | let file = $("#upload_bg")[0].files[0]; 1321 | let reader = new FileReader(); 1322 | reader.onloadend = function (e) { 1323 | let base64 = e.target.result; 1324 | $('#backgroundImgUrl').val(base64); 1325 | $('#backgroundImgUrl').change(); 1326 | } 1327 | reader.readAsDataURL(file); 1328 | }); 1329 | 1330 | // 搜博主文章 1331 | let searchBlogCookie = config.get("searchBlog", false); 1332 | if(searchBlogCookie) { 1333 | $('#recommend-right').append($('#asideSearchArticle').prop("outerHTML")); 1334 | setTimeout(function() { 1335 | $('#asideSearchArticle').attr("style", "margin-top: 8px; width: 300px;"); 1336 | var i = $("#search-blog-words") 1337 | , n = $(".btn-search-blog"); 1338 | i.keyup(function(t) { 1339 | var n = t.keyCode; 1340 | if (13 == n) { 1341 | var e = encodeURIComponent(i.val()); 1342 | if (e) { 1343 | var s = "//so.csdn.net/so/search/s.do?q=" + e + "&t=blog&u=" + username; 1344 | window.open(s) 1345 | } 1346 | } 1347 | }); 1348 | n.on("click", function(t) { 1349 | var n = encodeURIComponent(i.val()); 1350 | if (n) { 1351 | var e = "//so.csdn.net/so/search/s.do?q=" + n + "&t=blog&u=" + username; 1352 | window.open(e) 1353 | } 1354 | t.preventDefault() 1355 | }); 1356 | }, 500); 1357 | } 1358 | if (searchBlogCookie) { 1359 | $("#toggle-searchblog-button").prop("checked", true); 1360 | } else { 1361 | $("#toggle-searchblog-button").prop("checked", false); 1362 | } 1363 | config.listenButton("#toggle-searchblog-button", "searchBlog", 1364 | function() {location.reload();}, 1365 | function() {location.reload();}); 1366 | 1367 | // 最新文章 1368 | let newArticleCookie = config.get("newArticle", false); 1369 | if (newArticleCookie) { 1370 | $('#recommend-right').append($('#asideNewArticle').prop("outerHTML")); 1371 | setTimeout(function() { 1372 | $('#asideNewArticle').attr("style", "margin-top: 8px; width: 300px;"); 1373 | }, 0); 1374 | } 1375 | if (newArticleCookie) { 1376 | $("#toggle-newarticle-button").prop("checked", true); 1377 | } else { 1378 | $("#toggle-newarticle-button").prop("checked", false); 1379 | } 1380 | config.listenButton("#toggle-newarticle-button", "newArticle", 1381 | function() {location.reload();}, 1382 | function() {location.reload();}); 1383 | 1384 | // 热门文章 1385 | let hotArticleCookie = config.get("hotArticle", false); 1386 | if (hotArticleCookie) { 1387 | $('#recommend-right').append($("#asideHotArticle").prop("outerHTML")); 1388 | setTimeout(function() { 1389 | $('#asideHotArticle').attr("style", "margin-top: 8px; width: 300px;"); 1390 | $('#asideHotArticle img').remove(); 1391 | }, 0); 1392 | } 1393 | if (hotArticleCookie) { 1394 | $("#toggle-hotarticle-button").prop("checked", true); 1395 | } else { 1396 | $("#toggle-hotarticle-button").prop("checked", false); 1397 | } 1398 | config.listenButton("#toggle-hotarticle-button", "hotArticle", 1399 | function() {location.reload();}, 1400 | function() {location.reload();}); 1401 | 1402 | // 最新评论 1403 | let newCommentsCookie = config.get("newComments", false); 1404 | if (newCommentsCookie) { 1405 | $('#recommend-right').append($("#asideNewComments").prop("outerHTML")); 1406 | setTimeout(function() { 1407 | $('#asideNewComments').attr("style", "margin-top: 8px; width: 300px;"); 1408 | $(".comment.ellipsis").attr("style", "max-height: none;"); 1409 | $(".title.text-truncate").attr("style", "padding: 0"); 1410 | }, 0); 1411 | } 1412 | if (newCommentsCookie) { 1413 | $("#toggle-newcomments-button").prop("checked", true); 1414 | } else { 1415 | $("#toggle-newcomments-button").prop("checked", false); 1416 | } 1417 | config.listenButton("#toggle-newcomments-button", "newComments", 1418 | function() {location.reload();}, 1419 | function() {location.reload();}); 1420 | 1421 | // 分类专栏 1422 | let kindPersonCookie = config.get("kindPerson", false); 1423 | if (!kindPersonCookie) { 1424 | setTimeout(function() { 1425 | $('#asideCategory').remove(); 1426 | $('.kind_person').remove(); 1427 | }, 0); 1428 | } else { 1429 | $('#recommend-right').append($("#asideCategory").prop("outerHTML")); 1430 | if ($("#asideCategory").length > 0) { 1431 | $('.kind_person').remove(); 1432 | } else { 1433 | $('.kind_person').attr("style", "margin-top: 8px; width: 300px; height:255px;"); 1434 | } 1435 | setTimeout(function() { 1436 | $('#asideCategory').attr("style", "margin-top: 8px; width: 300px; display:block !important;"); 1437 | $("a.flexible-btn").click(function() { 1438 | $(this).parents('div.aside-box').removeClass('flexible-box'); 1439 | $(this).parents("p.text-center").remove(); 1440 | }) 1441 | }, 500); 1442 | } 1443 | if (kindPersonCookie) { 1444 | $("#toggle-kindperson-button").prop("checked", true); 1445 | } else { 1446 | $("#toggle-kindperson-button").prop("checked", false); 1447 | } 1448 | config.listenButton("#toggle-kindperson-button", "kindPerson", 1449 | function() {location.reload();}, 1450 | function() {location.reload();}); 1451 | 1452 | // 目录 1453 | let contentCookie = config.get("content", true); 1454 | if (!contentCookie) { 1455 | setTimeout(function() { 1456 | $('.align-items-stretch.group_item').parent().remove(); 1457 | }, 0); 1458 | } 1459 | if (contentCookie) { 1460 | $("#toggle-content-button").prop("checked", true); 1461 | } else { 1462 | $("#toggle-content-button").prop("checked", false); 1463 | } 1464 | config.listenButton("#toggle-content-button", "content", 1465 | function() {location.reload();}, 1466 | function() {location.reload();}); 1467 | 1468 | // 推荐文章 1469 | let recommendArticleCookie = config.get("recommendArticle", false); 1470 | if (!recommendArticleCookie) { 1471 | setTimeout(function() { 1472 | $('.recommend-list-box').remove(); 1473 | }, 0); 1474 | } else { 1475 | setTimeout(function() { 1476 | $('.recommend-list-box').attr("style", "margin-top: 8px; width: 300px; height:255px;"); 1477 | }, 0); 1478 | } 1479 | if (recommendArticleCookie) { 1480 | $("#toggle-recommendarticle-button").prop("checked", true); 1481 | } else { 1482 | $("#toggle-recommendarticle-button").prop("checked", false); 1483 | } 1484 | config.listenButton("#toggle-recommendarticle-button", "recommendArticle", 1485 | function() {location.reload();}, 1486 | function() {location.reload();}); 1487 | 1488 | // 归档 1489 | let archiveCookie = config.get("archive", false); 1490 | if (!archiveCookie) { 1491 | setTimeout(function() { 1492 | $('#asideArchive').remove(); 1493 | }, 0); 1494 | } else { 1495 | $('#recommend-right').append($("#asideArchive").prop("outerHTML")); 1496 | setTimeout(function() { 1497 | $('#asideArchive').attr("style", "margin-top: 8px; width: 300px; display:block !important;"); 1498 | }, 500); 1499 | } 1500 | if (archiveCookie) { 1501 | $("#toggle-archive-button").prop("checked", true); 1502 | } else { 1503 | $("#toggle-archive-button").prop("checked", false); 1504 | } 1505 | config.listenButton("#toggle-archive-button", "archive", 1506 | function() {location.reload();}, 1507 | function() {location.reload();}); 1508 | 1509 | // 自动靠左平铺 1510 | let autoSizeCookie = config.get("autoSize", false); 1511 | if (autoSizeCookie) { 1512 | setInterval(function () { 1513 | // 文章宽度自适应 1514 | if (window.innerWidth < 1100) { 1515 | // 删除原有响应式样式 1516 | $(".main_father").removeClass("justify-content-center"); 1517 | $("article").width(window.innerWidth - 150); 1518 | GM_addStyle(` 1519 | main{ 1520 | width: auto!important; 1521 | float: none!important; 1522 | max-width: 90vw; 1523 | } 1524 | main article img{ 1525 | margin: 0 auto; 1526 | max-width: 100%; 1527 | object-fit: cover; 1528 | } 1529 | `); 1530 | did = true; 1531 | } else { 1532 | if (did === true) { 1533 | $("article").removeAttr("style"); 1534 | did = false; 1535 | } 1536 | } 1537 | }, 500); 1538 | } 1539 | if (autoSizeCookie) { 1540 | $("#toggle-autosize-button").prop("checked", true); 1541 | } else { 1542 | $("#toggle-autosize-button").prop("checked", false); 1543 | } 1544 | config.listenButton("#toggle-autosize-button", "autoSize", 1545 | function() {location.reload();}, 1546 | function() {location.reload();}); 1547 | 1548 | // 自动隐藏顶栏 1549 | let autoHideToolbarCookie = config.get("autoHideToolbar", true); 1550 | if (autoHideToolbarCookie) { 1551 | $(window).scroll(function() { 1552 | if (document.documentElement.scrollTop > 100) { 1553 | let scrollS = $(this).scrollTop(); 1554 | if (scrollS >= windowTop) { 1555 | $('#csdn-toolbar').slideUp(100); 1556 | windowTop = scrollS; 1557 | } else { 1558 | $('#csdn-toolbar').slideDown(100); 1559 | windowTop = scrollS; 1560 | } 1561 | } 1562 | }); 1563 | } 1564 | if (autoHideToolbarCookie) { 1565 | $("#toggle-autohidetoolbar-button").prop("checked", true); 1566 | } else { 1567 | $("#toggle-autohidetoolbar-button").prop("checked", false); 1568 | } 1569 | config.listenButton("#toggle-autohidetoolbar-button", "autoHideToolbar", 1570 | function() {location.reload();}, 1571 | function() {location.reload();}); 1572 | 1573 | // 自动隐藏底栏 1574 | let autoHideBottomBarCookie = config.get("autoHideBottomBar", true); 1575 | if (autoHideBottomBarCookie) { 1576 | $("#toolBarBox .left-toolbox").css({ 1577 | position: "relative", 1578 | left: "0px", 1579 | bottom: "0", 1580 | width: $("#toolBarBox").width() + "px" 1581 | }); 1582 | $(window).scroll(function() { 1583 | $("#toolBarBox .left-toolbox").css({ 1584 | position: "relative", 1585 | left: "0px", 1586 | bottom: "0", 1587 | width: $("#toolBarBox").width() + "px" 1588 | }) 1589 | }); 1590 | } 1591 | if (autoHideBottomBarCookie) { 1592 | $("#toggle-autohidebottombar-button").prop("checked", true); 1593 | } else { 1594 | $("#toggle-autohidebottombar-button").prop("checked", false); 1595 | } 1596 | config.listenButton("#toggle-autohidebottombar-button", "autoHideBottomBar", 1597 | function() {location.reload();}, 1598 | function() {location.reload();}); 1599 | 1600 | // 创作中心按钮 1601 | let writeBlogCookie = config.get("writeBlog", true); 1602 | if (!writeBlogCookie) { 1603 | $(".toolbar-btn-write").remove(); 1604 | } 1605 | if (writeBlogCookie) { 1606 | $("#toggle-writeblog-button").prop("checked", true); 1607 | } else { 1608 | $("#toggle-writeblog-button").prop("checked", false); 1609 | } 1610 | config.listenButton("#toggle-writeblog-button", "writeBlog", 1611 | function() {location.reload();}, 1612 | function() {location.reload();}); 1613 | 1614 | // 右侧滚动条 1615 | /** setTimeout(function () { 1616 | let rightSideHeight = 0; 1617 | let pageHeight = $(window).height(); 1618 | rightSideHeight += getHeight($('.align-items-stretch.group_item').parent()); 1619 | rightSideHeight += getHeight($("#asideProfile")); 1620 | rightSideHeight += getHeight($("#asideSearchArticle")); 1621 | rightSideHeight += getHeight($("#asideNewArticle")); 1622 | rightSideHeight += getHeight($("#asideHotArticle")); 1623 | rightSideHeight += getHeight($("#asideNewComments")); 1624 | rightSideHeight += getHeight($("#asideCategory")); 1625 | rightSideHeight += getHeight($("#asideArchive")); 1626 | console.debug("Right side total height: " + rightSideHeight); 1627 | console.debug("Page height: " + pageHeight); 1628 | if (rightSideHeight > pageHeight) { 1629 | $('#recommend-right').css("overflow", "scroll"); 1630 | } 1631 | }, 1500); */ 1632 | } else if (num === 7) { 1633 | $(".me_r")[1].remove(); 1634 | } else if (num === 8) { 1635 | /* $(".article-bar-top").append("
"); 1636 | $(".article-bar-top").append($(".aside-box-footerClassify").children("dd").html()); 1637 | $("dl").each(function (index, element) { 1638 | var key = $(this).children("dt"); 1639 | var value = $(this).children("dd").children("span"); 1640 | if (key.html().indexOf("原创") != -1) { 1641 | key = $(this).children("dt").children("a") 1642 | value = $(this).children("dd").children("a").children("span"); 1643 | addInfo(key, value); 1644 | } else 1645 | if (value.html() != undefined) { 1646 | addInfo(key, value); 1647 | } 1648 | } ); 1649 | function addInfo(key, value) { 1650 | var bind = key.html() + " " + value.html() + "  "; 1651 | $(".article-bar-top").append(bind + " "); 1652 | } */ 1653 | $(".blog_container_aside").remove(); 1654 | $(".toolbox-left > .profile-attend").remove(); 1655 | 1656 | // 标题消息提醒去除 1657 | let title = document.title.replace(/^\(.*?\)/g, ""); 1658 | document.title = title; 1659 | // 评论复制按钮 1660 | $('.comment-box').prepend(''); 1661 | $('.new-opt-box.new-opt-box-bg').prepend('复制评论'); 1662 | $('.btn-copy').click(function() { 1663 | var clipboard = new ClipboardJS('.comment-hidden-text'); 1664 | clipboard.on('success', function(e) { 1665 | console.info('Action:', e.action); 1666 | console.info('Text:', e.text); 1667 | console.info('Trigger:', e.trigger); 1668 | e.clearSelection(); 1669 | $('.btn-copy').html('成功'); 1670 | setTimeout(function() { 1671 | $('.btn-copy').html('复制评论'); 1672 | }, 1000); 1673 | }); 1674 | clipboard.on('error', function(e) { 1675 | console.error('Action:', e.action); 1676 | console.error('Trigger:', e.trigger); 1677 | $('.btn-copy').html('失败,请手动复制'); 1678 | setTimeout(function() { 1679 | $('.btn-copy').html('复制评论'); 1680 | }, 1000); 1681 | }); 1682 | $(".comment-hidden-text").click(); 1683 | clipboard.destroy(); 1684 | }); 1685 | } else if (num === 9) { 1686 | // 删除CSDN LOGO悬浮后的二维码 1687 | $(".toolbar-subMenu > img").parent().remove(); 1688 | } 1689 | }, 100); 1690 | progressor.incProgress(10); 1691 | } 1692 | 1693 | function showTips() { 1694 | var config = { 1695 | content: "欢迎使用 CSDNGreener,绿化设定按钮在这里!
好的,以后不再提示我", 1696 | type: "html", 1697 | alignTo: ["bottom", "right"], 1698 | trigger: "show", 1699 | isclose: false, 1700 | color: ["#B2E281", "#B2E281"] 1701 | }; 1702 | $("#greenerSettings").showTips(config); 1703 | } 1704 | 1705 | function getHeight(element) { 1706 | let outerHeight = element.outerHeight(); 1707 | if (outerHeight === null) { 1708 | return 0; 1709 | } 1710 | return outerHeight; 1711 | } 1712 | 1713 | function isFirefox() { 1714 | return navigator.userAgent.indexOf("Firefox") > 0; 1715 | } 1716 | --------------------------------------------------------------------------------