贴吧首页优化

美化贴吧首页显示,只保留动态和已关注贴吧,并且显示所有已关注贴吧

目前为 2020-04-20 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 贴吧首页优化
  3. // @namespace Violentmonkey Scripts
  4. // @description 美化贴吧首页显示,只保留动态和已关注贴吧,并且显示所有已关注贴吧
  5. // @version 1.0.0
  6. // @author mzr1996
  7. // @include *://tieba.baidu.com/#
  8. // @include *://tieba.baidu.com/
  9. // @include *://tieba.baidu.com/index*
  10. // @run-at document-body
  11. // @license MIT
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. // ==== Tips =====
  16. // 本脚本受@BackRunner的“贴吧页面精简脚本”启发,增删了部分功能
  17. // 如果需要功能更加强大、可定制化的精简效果请使用上述脚本
  18. // 2020-4-20在本人电脑上使用Firefox测试没有问题
  19. // 然本人JS小白,不保证脚本的持续更新和兼容性
  20. // 如果你有好的修改意见,欢迎使用本脚本做二次修改或联系本人
  21. // ================
  22.  
  23. (function(){
  24. "use strict";
  25. var startTime = new Date().getTime();
  26. //控制台信息
  27. console.warn('贴吧主页优化开始');
  28. // 触发ajax,加载更多关注贴吧
  29. $('#moreforum').trigger("mouseover");
  30. $('#moreforum').trigger("mouseout");
  31. // 将更多关注贴吧添加至左侧边栏
  32. var likeforumwrapper = document.getElementById('likeforumwraper');
  33. var morelikelist = document.getElementById('forumscontainer').firstChild.firstChild.childNodes;
  34. for (var i = 0;i<morelikelist.length;i++){
  35. if (morelikelist[i].className.indexOf('addnewforumbtn') == -1){
  36. var newitem = morelikelist[i].cloneNode(true);
  37. newitem.className += ' u-f-item';
  38. likeforumwrapper.appendChild(newitem);
  39. }
  40. }
  41. // 添加占位符以保证“添加爱逛的吧”另起一行
  42. if (morelikelist.length%2===0){
  43. var placeholder = document.createElement('a');
  44. placeholder.setAttribute('class','u-f-item');
  45. likeforumwrapper.appendChild(placeholder);
  46. }
  47. var addnewforumbtn = morelikelist[morelikelist.length-1];
  48. likeforumwrapper.appendChild(addnewforumbtn);
  49. configCSS();
  50. var finishTime = new Date().getTime() - startTime;
  51. console.log('贴吧主页优化用时: ' + finishTime);
  52. //修改CSS文件
  53. function configCSS(){
  54. var cssText = "";
  55. // 移除顶部滚动横幅
  56. cssText += '.top-sec {display: none !important;}';
  57. // 移除贴吧推荐
  58. cssText += '.r-top-sec {display: none !important;}';
  59. // 移除右侧二维码和热议榜
  60. cssText += '.r-right-sec {display: none !important;}';
  61. // 移除直播秀
  62. cssText += '.spage_liveshow_slide {display: none !important;}';
  63. // 移除我的游戏
  64. cssText += '#spage_game_tab_wrapper {display: none !important;}';
  65. // 移除贴吧精选专题
  66. cssText += '.aggregate_entrance_wrap {display: none !important;}';
  67. // 移除贴吧分类
  68. cssText += '.ufw-gap {display: none !important;}';
  69. cssText += '#f-d-w {display: none !important;}';
  70. // 移除更多关注贴吧按钮
  71. cssText += '#moreforum {display: none !important;}';
  72. cssText += '.pop-up-frame {display: none !important;}';
  73.  
  74. // “添加爱逛的吧”按钮配置
  75. cssText += '.addnewforumbtn {background: url(//tb2.bdstatic.com/tb/static-spage/img/css1_44fc180.png) no-repeat; _background: url(//tb2.bdstatic.com/tb/static-spage/img/css1_7481ade.gif) no-repeat; background-position: -524px -208px;line-height: 35px;padding-left: 6px;color: #444;float: left;height: 35px;margin-bottom: 3px;overflow: hidden;width: 168px;position: relative;margin-left: 8px;_margin-left: 9px;}';
  76. // “爱逛的吧”边栏禁止滚动
  77. cssText += '.left-cont-fixed {position:unset !important;}';
  78. // 修改动态样式
  79. cssText += '.new_list {margin: 18px 0 0;}';
  80. cssText += '.j_feed_li {border-style: dashed solid none solid;border-width: 1px;padding: 10px;border-color: #E2D8D6;}';
  81. cssText += '.home-place-item {display: none !important;}';
  82. cssText += '.n_right {width: 530px;}';
  83. // 应用CSS
  84. var element = document.createElement('link');
  85. element.rel="stylesheet";
  86. element.type="text/css";
  87. element.href='data:text/css,'+cssText;
  88.  
  89. document.documentElement.appendChild(element);
  90. var modStyle = document.querySelector('#modCSS');
  91. if (modStyle === null){
  92. modStyle = document.createElement('style');
  93. modStyle.id = 'modCSS';
  94. document.body.appendChild(modStyle);
  95. modStyle.innerHTML = cssText;
  96. }
  97. }
  98. })();

QingJ © 2025

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