hipda 论坛热度高亮 + 只显示最近一天的帖子

参考论友 wu-lamplamp的 hipda 论坛热度高亮+top 按钮修复修改

目前为 2022-06-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name hipda 论坛热度高亮 + 只显示最近一天的帖子
  3. // @description 参考论友 wu-lamplamp的 hipda 论坛热度高亮+top 按钮修复修改
  4. // @description 0.80适配论坛新域名
  5. // @description 0.70修改 又该jquery镜像地址,优化部分逻辑
  6. // @description 0.60修改 一周的帖子太多,只查看一天的帖子。如果12点之前,则还可以查看前一天的帖子。
  7. // @description 0.50增加 单条帖子的屏蔽按钮 X
  8. // @description 0.40修正 因帖子在列表不同的翻页的url不同, 而造成的查看过的页面重新出现的bug。
  9. // @description 0.30修正 bs版 查看过的帖子在列表中隐藏的功能无效的问题
  10. // @description 0.20增加查看过的帖子在列表中隐藏的功能
  11. // @description 0.10保留论坛高亮功能 去除top按钮功能 增加只显示最近一周的帖子帖子的功能
  12. // @description 修改界面宽度,放大标题字体
  13. // @namespace www.91mdz.com
  14. // @include https://www.hi-pda.com/forum/forumdisplay.php?*
  15. // @include https://www.4d4y.com/forum/forumdisplay.php?*
  16. // @version 0.8.0
  17. // @require https://cdn.staticfile.org/jquery/1.12.1/jquery.min.js
  18. // @grant none
  19. // @license MIT
  20. // ==/UserScript==
  21.  
  22. var now_time = new Date();
  23. var day_count = 2;
  24. //12点之后,只看当天的帖子
  25. if ( now_time.getHours() > 12 )
  26. {
  27. day_count = day_count - 1;
  28. }
  29. var hide_space = day_count * 24 * 60 * 60 * 1000;
  30.  
  31. //是点击否查看过的帖子隐藏
  32. var click_hide = true;
  33.  
  34. var jq = jQuery.noConflict();
  35.  
  36. var m = function (f) {
  37. return f.toString().split('\n').slice(1, - 1).join('\n');
  38. };
  39.  
  40. var loadCss = function () {
  41. var style = document.createElement('style');
  42. style.type = 'text/css';
  43. style.textContent = m(function () { /*
  44. #postlist{border: 1px solid #ccc;}
  45. #nav, #nav a {
  46. color: #000000;
  47. }
  48. body{
  49. background:#fff;
  50. }
  51. .postauthor .profile, .postbottom {
  52. display:none;
  53. }
  54. .t_msgfontfix {
  55. min-height:0px !important;
  56. }
  57. body{
  58. margin: 0 auto;
  59. width: 90%;
  60. font-size: 16px;
  61. }
  62. .wrap, #nav{
  63. width:100%;
  64. }
  65. a:visited{
  66. color:#aaa;
  67. }
  68. div#header div.wrap h2{
  69. display:none;
  70. }
  71. .main{border:1px #ccc solid;}
  72. */
  73. });
  74. var head = document.querySelector('head');
  75. head.appendChild(style);
  76. };
  77.  
  78. function checkLink( url )
  79. {
  80. return localStorage.getItem( url ) > 0;
  81. }
  82.  
  83. function saveLink( url )
  84. {
  85. localStorage.setItem( url, 1 );
  86. }
  87.  
  88. function onLinkClick( obj )
  89. {
  90. var id = obj.currentTarget.id;
  91. saveLink( id );
  92.  
  93. if( click_hide )
  94. {
  95. jq( obj.currentTarget ).hide();
  96. }
  97. }
  98.  
  99. loadCss();
  100.  
  101. jq( dispost );
  102. function dispost(){
  103. jq('tbody').each(function () {
  104. var create_time = new Date(jq('.author em', this).text());
  105. create_time = Date.parse(create_time);
  106.  
  107. var num = parseInt(jq('.nums strong', this).text());
  108. if( (now_time - create_time ) < hide_space )
  109. {
  110. if (num > 100)
  111. {
  112. jq(this).css('background', '#FFEBEB');
  113. }
  114. else if (num > 50)
  115. {
  116. jq(this).css('background', '#FFCDCD');
  117. }
  118. else if (num > 20)
  119. {
  120. jq(this).css('background', '#FFEBEB');
  121. }
  122. }
  123. else
  124. {
  125. jq( this ).hide();
  126. }
  127.  
  128. var id = this.id;
  129. if ( id )
  130. {
  131. if( checkLink( id ) )
  132. {
  133. jq( this ).hide();
  134. }
  135. else
  136. {
  137. var link = jq('.subject span a', this)[0];
  138. jq(link).attr('target', '_blank');
  139. jq(this).click(onLinkClick);
  140. }
  141. }
  142. });
  143. }