hide S1 ads (x)

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         hide S1 ads (x)
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  隐藏大量发帖无人回复者(就是你,广告哥)的帖子,自动加载下一页以凑到30贴以上
// @author       whzfjk
// @match        https://bbs.saraba1st.com/2b/forum-*-*.html
// @grant        none
// ==/UserScript==

function killAds() {
    'use strict';

    var post_threshold = 4;
    var replied_threshold = 2;

    var rst = document.evaluate( '//*[starts-with(@id, "normalthread_")]', document, null, XPathResult.ANY_TYPE, null);
    var post = rst.iterateNext();
    var collect = new Map();
    var remain = 0;
    while (post) {
        remain += 1;
        var name = post.querySelector('cite > a').text;
        if (!collect.get(name)) {
            collect.set(name, {cnt: 0, noreply_cnt: 0, posts: []});
        }
        var ent = collect.get(name);
        ent.cnt += 1;
        var reply = parseInt(post.querySelector('tr > td.num > a').text);
        if (reply === 0) {
            ent.noreply_cnt += 1;
        }
        ent.posts.push(post);
        post = rst.iterateNext();
    }

    for (var [k, v] of collect) {
        if (v.cnt > post_threshold && v.cnt - v.noreply_cnt < replied_threshold) {
            console.log("prepare to hide " + k);
            for (var p of v.posts) {
                p.hidden = true;
            }
            remain -= v.posts.length;
        }
    }

    return remain;
}

(function() {
    'use strict';
    var nextPage = document.querySelector('#autopbn');
    for (var posts = killAds(); posts < 30; posts = killAds()) {
        console.log('need more posts');
        nextPage.click();
    }
})();