🏠 Home 

hide S1 ads (x)

隐藏大量发帖无人回复者(就是你,广告哥)的帖子,自动加载下一页以凑到30贴以上


安装此脚本?
  1. // ==UserScript==
  2. // @name hide S1 ads (x)
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description 隐藏大量发帖无人回复者(就是你,广告哥)的帖子,自动加载下一页以凑到30贴以上
  6. // @author whzfjk
  7. // @match https://bbs.saraba1st.com/2b/forum-*-*.html
  8. // @grant none
  9. // ==/UserScript==
  10. function killAds() {
  11. 'use strict';
  12. var post_threshold = 4;
  13. var replied_threshold = 2;
  14. var rst = document.evaluate( '//*[starts-with(@id, "normalthread_")]', document, null, XPathR###lt.ANY_TYPE, null);
  15. var post = rst.iterateNext();
  16. var collect = new Map();
  17. var remain = 0;
  18. while (post) {
  19. remain += 1;
  20. var name = post.querySelector('cite > a').text;
  21. if (!collect.get(name)) {
  22. collect.set(name, {cnt: 0, noreply_cnt: 0, posts: []});
  23. }
  24. var ent = collect.get(name);
  25. ent.cnt += 1;
  26. var reply = parseInt(post.querySelector('tr > td.num > a').text);
  27. if (reply === 0) {
  28. ent.noreply_cnt += 1;
  29. }
  30. ent.posts.push(post);
  31. post = rst.iterateNext();
  32. }
  33. for (var [k, v] of collect) {
  34. if (v.cnt > post_threshold && v.cnt - v.noreply_cnt < replied_threshold) {
  35. console.log("prepare to hide " + k);
  36. for (var p of v.posts) {
  37. p.hidden = true;
  38. }
  39. remain -= v.posts.length;
  40. }
  41. }
  42. return remain;
  43. }
  44. (function() {
  45. 'use strict';
  46. var nextPage = document.querySelector('#autopbn');
  47. for (var posts = killAds(); posts < 30; posts = killAds()) {
  48. console.log('need more posts');
  49. nextPage.click();
  50. }
  51. })();