hide S1 ads (x)

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

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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