🔥持续更新🔥 简书 jianshu.com 广告完全过滤、人性化脚本优化:Greener系列的新产品,有口皆碑超好用。

⚡️拥有数项独家功能的最强简书脚本,不服比一比⚡️|🕶继CSDNGreener的又一力作,一样的实用美观|🖥主页滑动自动加载,无需手动点击|

  1. // ==UserScript==
  2. // @name 🔥持续更新🔥 简书 jianshu.com 广告完全过滤、人性化脚本优化:Greener系列的新产品,有口皆碑超好用。
  3. // @namespace https://github.com/adlered
  4. // @version 1.0.1
  5. // @description ⚡️拥有数项独家功能的最强简书脚本,不服比一比⚡️|🕶继CSDNGreener的又一力作,一样的实用美观|🖥主页滑动自动加载,无需手动点击|
  6. // @author Adler
  7. // @connect www.jianshu.com
  8. // @include *://*.jianshu.com/*
  9. // @require https://cdn.jsdelivr.net/npm/jquery@1.11.0/dist/jquery.min.js
  10. // @require https://cdn.jsdelivr.net/npm/jquery.cookie/jquery.cookie.js
  11. // @require https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.js
  12. // @require https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js
  13. // @contributionURL https://doc.stackoverflow.wiki/web/#/21?page_id=138
  14. // @grant GM_addStyle
  15. // @note 21-07-20 1.0.1 去除更多广告
  16. // @note 21-07-20 1.0.0 初版发布
  17. // ==/UserScript==
  18. var version = "1.0.1";
  19. var currentURL = window.location.href;
  20. if (currentURL.indexOf("?") !== -1) {
  21. currentURL = currentURL.substring(0, currentURL.indexOf("?"));
  22. }
  23. var list = [];
  24. var startTimeMilli = Date.now();
  25. var stopTimeMilli = 0;
  26. var timeoutInt;
  27.  
  28. // 配置控制类
  29. class Config {
  30. get(key, value) {
  31. var cookie = $.cookie(key);
  32. if (cookie == undefined) {
  33. new Config().set(key, value);
  34. console.debug("Renew key: " + key + " : " + value);
  35. return value;
  36. }
  37. console.debug("Read key: " + key + " : " + cookie);
  38. if (cookie === "true") { return true; }
  39. if (cookie === "false") { return false; }
  40. return cookie;
  41. }
  42.  
  43. set(setKey, setValue) {
  44. $.cookie(setKey, setValue, {
  45. path: '/',
  46. expires: 365
  47. });
  48. console.debug("Key set: " + setKey + " : " + setValue);
  49. }
  50.  
  51. listenButton(element, listenKey, trueAction, falseAction) {
  52. $(element).click(function () {
  53. let status = new Config().get(listenKey, true);
  54. console.debug("Status: " + status);
  55. if (status === "true" || status) {
  56. console.debug("Key set: " + listenKey + " :: " + false);
  57. new Config().set(listenKey, false);
  58. } else {
  59. console.debug("Key set: " + listenKey + " :: " + true);
  60. new Config().set(listenKey, true);
  61. }
  62. });
  63. }
  64.  
  65. listenButtonAndAction(element, listenKey, trueAction, falseAction) {
  66. $(element).click(function () {
  67. let status = new Config().get(listenKey, true);
  68. console.debug("Status: " + status);
  69. if (status === "true" || status) {
  70. console.debug("Key set: " + listenKey + " :: " + false);
  71. new Config().set(listenKey, false);
  72. falseAction();
  73. } else {
  74. console.debug("Key set: " + listenKey + " :: " + true);
  75. new Config().set(listenKey, true);
  76. trueAction();
  77. }
  78. });
  79. }
  80. }
  81.  
  82. //文档高度
  83. function getDocumentTop() {
  84. var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
  85. if (document.body) {
  86. bodyScrollTop = document.body.scrollTop;
  87. }
  88. if (document.documentElement) {
  89. documentScrollTop = document.documentElement.scrollTop;
  90. }
  91. scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
  92. return scrollTop;
  93. }
  94.  
  95. //可视窗口高度
  96. function getWindowHeight() {
  97. var windowHeight = 0;
  98. if (document.compatMode == "CSS1Compat") {
  99. windowHeight = document.documentElement.clientHeight;
  100. } else {
  101. windowHeight = document.body.clientHeight;
  102. }
  103. return windowHeight;
  104. }
  105.  
  106. //滚动条滚动高度
  107. function getScrollHeight() {
  108. var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
  109. if (document.body) {
  110. bodyScrollHeight = document.body.scrollHeight;
  111. }
  112. if (document.documentElement) {
  113. documentScrollHeight = document.documentElement.scrollHeight;
  114. }
  115. scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
  116. return scrollHeight;
  117. }
  118.  
  119. function l(log) {
  120. console.log("[JianShuGreener] " + log);
  121. }
  122.  
  123. function e(error) {
  124. console.error("[JianShuGreener] " + error);
  125. }
  126.  
  127. function clear() {
  128. list = [];
  129. }
  130.  
  131. function put(tag) {
  132. list.push(tag);
  133. }
  134.  
  135. function clean(times) {
  136. var loop = setInterval(function () {
  137. --times;
  138. if (times <= 0) {
  139. clearInterval(loop);
  140. }
  141. for (var k = 0; k < list.length; k++) {
  142. $(list[k]).remove();
  143. }
  144. }, 100);
  145. }
  146.  
  147. function loop(num) {
  148. setInterval(function () {
  149. if (num === 1) {
  150. // 主页穿插的广告
  151. $("div[aria-label='baidu-ad']").remove();
  152. }
  153. }, 500);
  154. }
  155.  
  156. function common(times, f) {
  157. var loop = setInterval(function () {
  158. --times;
  159. if (times <= 0) {
  160. clearInterval(loop);
  161. }
  162. f();
  163. }, 100);
  164. NProgress.inc();
  165. }
  166.  
  167. (function () {
  168. 'use strict';
  169.  
  170. l("欢迎使用 JianShuGreener V" + version + ",页面优化中...");
  171. NProgress.start();
  172.  
  173. let config = new Config();
  174. var blockURL = currentURL.split("/").length;
  175.  
  176. var homePage = /(www\.jianshu\.com\/)$/;
  177. var articlePage = /\/p\//;
  178. var itPage = /\/techareas\/backend/;
  179. var notifyPage = /\/notifications\#\//;
  180. var settingsPage = /\/settings\//;
  181. var subscribePage = /\/subscriptions\#\//;
  182.  
  183. if (homePage.test(currentURL)) {
  184. l("正在优化主页浏览体验...");
  185.  
  186. common(5, function() {
  187. // 上栏抽奖
  188. $("a:contains('抽奖')").parent().remove();
  189. // 右下角红包
  190. $("img[src='//cdn2.jianshu.io/assets/web/close_luck-29c555eb1a1fc84e0df2284fb668fbae.png']").parent().parent().remove();
  191. // 顶栏下载App
  192. $(".menu-text:contains('下载App')").parent().remove();
  193. });
  194.  
  195. // 右侧下载简书二维码
  196. put("#index-aside-download-qrbox");
  197. // 右侧谷歌广告
  198. put("div[aria-label='3rd-ad']");
  199. // 推荐作者
  200. put(".recommended-author-wrap");
  201. // 页脚
  202. put("footer");
  203.  
  204. window.onscroll = function () {
  205. setTimeout(function () {
  206. if (timeoutInt != undefined) {
  207. window.clearTimeout(timeoutInt);
  208. }
  209. timeoutInt = window.setTimeout(function () {
  210. //监听事件内容
  211. if(getScrollHeight() == getDocumentTop() + getWindowHeight()){
  212. document.getElementsByClassName('load-more')[0].click()
  213. l("触发自动加载阅读更多");
  214. }
  215. }, 105);
  216. }, 100);
  217. }
  218.  
  219. loop(1);
  220. } else if (articlePage.test(currentURL)) {
  221. l("正在优化文章页浏览体验...");
  222.  
  223. common(5, function() {
  224. // 顶栏下载App
  225. $("a:contains('下载APP')").remove();
  226. // 悬浮抽奖图标
  227. $("div:contains('抽奖'):last").parent().parent().remove();
  228. // 更多好文按钮
  229. $("div:contains('更多好文'):last").parent().remove();
  230. });
  231.  
  232. // 简书钻
  233. put("span[aria-label='简书钻']");
  234. // 右侧谷歌广告
  235. put("section[aria-label='baidu-ad']");
  236. // 右侧星辰广告
  237. setTimeout(function() {
  238. $("section[aria-label='xingchen-ad']").remove();
  239. }, 1000);
  240. } else if (itPage.test(currentURL)) {
  241. l("正在优化IT技术页浏览体验...");
  242.  
  243. common(5, function() {
  244. // 顶栏下载App
  245. $(".menu-text:contains('下载App')").parent().remove();
  246. });
  247. } else if (notifyPage.test(currentURL)) {
  248. l("正在优化通知页浏览体验...");
  249.  
  250. // 左侧谷歌广告
  251. put("div[aria-label='3rd-ad']");
  252.  
  253. common(5, function() {
  254. // 上栏抽奖
  255. $("a:contains('抽奖')").parent().remove();
  256. });
  257. } else if (settingsPage.test(currentURL)) {
  258. l("正在优化设置页浏览体验...");
  259.  
  260. // 左侧谷歌广告
  261. put("div[aria-label='3rd-ad']");
  262.  
  263. common(5, function() {
  264. // 上栏抽奖
  265. $("a:contains('抽奖')").parent().remove();
  266. });
  267. } else if (subscribePage.test(currentURL)) {
  268. l("正在优化关注页浏览体验...");
  269.  
  270. common(5, function() {
  271. // 上栏抽奖
  272. $("a:contains('抽奖')").parent().remove();
  273. });
  274.  
  275. window.onscroll = function () {
  276. setTimeout(function () {
  277. if (timeoutInt != undefined) {
  278. window.clearTimeout(timeoutInt);
  279. }
  280. timeoutInt = window.setTimeout(function () {
  281. //监听事件内容
  282. if(getScrollHeight() == getDocumentTop() + getWindowHeight()){
  283. document.getElementsByClassName('load-more')[0].click()
  284. l("触发自动加载阅读更多");
  285. }
  286. }, 105);
  287. }, 100);
  288. }
  289. } else {
  290. l("正在尝试优化浏览体验...");
  291.  
  292. common(5, function() {
  293. // 上栏抽奖
  294. $("a:contains('抽奖')").parent().remove();
  295. });
  296. }
  297.  
  298. clean(10);
  299.  
  300. NProgress.done();
  301. stopTimeMilli = Date.now();
  302. l("优化完毕! 耗时 " + (stopTimeMilli - startTimeMilli) + "ms");
  303. })();

QingJ © 2025

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