5ch_ng_thread2

5ちゃんねるのスレッドをNGワードで消す。

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        5ch_ng_thread2
// @namespace   http://catherine.v0cyc1pp.com/5ch_ng_thread2.user.js
// @include     http://*.5ch.net/*
// @include     https://*.5ch.net/*
// @include     http://*.bbspink.com/*
// @include     https://*.bbspink.com/*
// @author      greg10
// @run-at      document-end
// @license     GPL 3.0
// @version     2.0
// @grant       none
// @description 5ちゃんねるのスレッドをNGワードで消す。
// ==/UserScript==


//================================
// Configurations
//   - NGワードを指定してください。
var g_nglist = [
    "見たくないスレッド",
    "見たくないスレッド2",
    "見たくないスレッド3",
];
//================================



console.log("5ch_ng_thread start");

//スレッドは3種ある
//板トップdiv.THREAD_MENUからのスレッド削除
function thread_menu() {
    document.querySelectorAll("div.THREAD_MENU p").forEach(function(elem) {
        var str = elem.innerText;
        if (str == null || str == undefined) {
            str = "";
        }
        for (var i = 0; i < g_nglist.length; ++i) {
            var ngword = g_nglist[i];
            if (ngword == "") {
                continue;
            }
            var obj = new RegExp(ngword, "i");
            var index = str.search(obj);
            if (index != -1) {
                elem.remove();
            }
        }
    });
}

//板トップdiv.THREAD_CONTENTSからのスレッド削除
function thread_contents() {
    document.querySelectorAll("div.THREAD_CONTENTS").forEach(function(elem) {
        var kids = elem.children;
        var str = "";
        for (var i = 0; i < kids.length; i++) {
            if (kids[i].classList.contains("thread_title")) {
                str = kids[i].innerText;
            }
        }
        if (str == null || str == undefined) {
            str = "";
        }
        for (i = 0; i < g_nglist.length; ++i) {
            var ngword = g_nglist[i];
            if (ngword == "") {
                continue;
            }
            var obj = new RegExp(ngword, "i");
            var index = str.search(obj);
            if (index != -1) {
                elem.remove();
            }
        }
    });
}

//スレッド全一覧はこちら からのスレッド削除
function thread_ichiran() {
    document.querySelectorAll("#trad > a").forEach(function(elem) {
        var str = elem.innerText;
        if (str == null || str == undefined) {
            str = "";
        }
        for (var i = 0; i < g_nglist.length; ++i) {
            var ngword = g_nglist[i];
            if (ngword == "") {
                continue;
            }
            var obj = new RegExp(ngword, "i");
            var index = str.search(obj);
            if (index != -1) {
                elem.remove();
            }
        }
    });
}

function main() {
    thread_menu();
    thread_contents();
    thread_ichiran();

}


main();