5ch_ng_honbun3

5ちゃんねるの本文をNGワードで消す。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        5ch_ng_honbun3
// @namespace   http://catherine.v0cyc1pp.com/
// @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     3.0
// @grant       none
// @description 5ちゃんねるの本文をNGワードで消す。
// ==/UserScript==


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



console.log("5ch_ng_honbun3 start");

// 本文は二種ある
//スレッドページからの本文削除
function honbun_post() {
    document.querySelectorAll("div.post").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.nextElementSibling.remove();
                elem.remove();
                return;
            }
        }
    });
}

//板トップdl.threadからの本文削除
function honbun_thread() {
    document.querySelectorAll("dl.thread > dd").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.previousElementSibling.remove();
                elem.remove();
                return;
            }
        }
    });
}

function main() {
    honbun_post();
    honbun_thread();
}


main();