个性化去广告升级配置版

写了一个小架子,不管你是编程老手还是小白,都可以根据这个架子定制自己的网站净化

  1. // ==UserScript==
  2. // @name 个性化去广告升级配置版
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.3
  5. // @description 写了一个小架子,不管你是编程老手还是小白,都可以根据这个架子定制自己的网站净化
  6. // @author 王子周棋洛
  7. // @match https://blog.csdn.net/*/article/details/*
  8. // @match https://www.baidu.com/
  9. // @match https://www.zhihu.com/explore
  10. // @match https://www.zhihu.com/question/*
  11. // @match https://zhuanlan.zhihu.com/p/*
  12. // @match https://webpack.docschina.org/concepts/
  13. // @icon http://zhouql.vip/images/icon/clear.png
  14. // @run-at document-start
  15. // @grant none
  16. // @license MIT
  17. // ==/UserScript==
  18.  
  19. // 这个版本做了性能优化,简单版本将配置全部注入,这个版本会在特定的网站上注入特定的配置
  20. // 只是配置有了约束,使用了对象配置,对象的key就是网站域名,value是一个数组,数组的值就是需要隐藏的元素
  21. (function () {
  22. // 只需要在此处定义需要隐藏元素
  23. var clearElementArr = [
  24. // csdn
  25. { "csdn.net": ['.passport-container', '.passport-login-mark'] },
  26. // 知乎
  27. { "zhihu.com": ['.css-1izy64v', '.css-ysn1om', '.Modal-wrapper'] },
  28. // 百度搜索
  29. { "baidu.com": ['#s-top-left', '#s_top_wrap', '.s-top-right', '#s_main', '.s-bottom-layer-content'] },
  30. // webpack官网
  31. { "webpack.docschina.org": ['.sponsors']}
  32. ];
  33.  
  34. // 这是架子代码,不用改动
  35. console.log("准备隐藏以下元素 >>> " + clearElementArr);
  36. let style = document.createElement("style");
  37. window.location.href.includes("zhihu.com") ? style.innerText += `html {overflow: auto !important;} ` : '';
  38. window.pageC = function (clearElements) {
  39. if (typeof (clearElements) === "object") {
  40. clearElementArr.forEach(o => {
  41. let key = Object.keys(o);
  42. if (window.location.href.includes(key)) {
  43. o[key].forEach(el => {
  44. style.innerText += `${el} {display: none !important;} `;
  45. })
  46. }
  47. })
  48. } else {
  49. console.error("param error,require array!");
  50. }
  51. style.innerText != '' ? document.head.appendChild(style) : '';
  52. };
  53. pageC(clearElementArr);
  54. console.log("清理完成!");
  55. })();
  56.  

QingJ © 2025

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