hide S1 ads (x)

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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();
    }
})();