Hide Low Heat Posts

隐藏热度低于150的帖子

当前为 2024-12-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Hide Low Heat Posts
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 隐藏热度低于150的帖子
  6. // @author Your Name
  7. // @match https://bbs.hupu.com/topic-daily-hot
  8. // @license LGPL
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 创建Hide按钮并添加到页面右上方
  16. const hideButton = document.createElement('button');
  17. hideButton.innerText = 'Hide';
  18. hideButton.style.position = 'fixed';
  19. hideButton.style.top = '10px';
  20. hideButton.style.right = '10px';
  21. hideButton.style.zIndex = '9999';
  22. document.body.appendChild(hideButton);
  23.  
  24. // 点击Hide按钮时执行函数
  25. hideButton.addEventListener('click', function() {
  26. // 找到所有帖子条目
  27. const posts = document.querySelectorAll('.bbs-sl-web-post-body');
  28. posts.forEach(post => {
  29. // 获取回复数
  30. const replyCountText = post.querySelector('.post-datum').innerText.split('/')[0].trim();
  31. const replyCount = parseInt(replyCountText, 10);
  32.  
  33. // 如果回复数小于150,则隐藏帖子条目
  34. if (replyCount < 150) {
  35. post.style.display = 'none';
  36. }
  37. });
  38. });
  39. })();