Published using Google Docs
あにまん掲示板用(クソコテ非表示)
Updated automatically every 5 minutes

// ==UserScript==

// @name             あにまん掲示板用(クソコテ非表示)

// @namespace        http://tampermonkey.net/

// @version          0.1

// @description  あにまん掲示板用のクソコテのレスを非表示にする

// @author           You

// @match            https://bbs.animanch.com/*

// @icon

// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js

// @grant            none

// ==/UserScript==

// bodyの内容変更を監視

var observer = new MutationObserver(function(){

        deleteResKusokote();

        deletePopupKusokote();

});

// bodyの内容変更を監視する設定

const config = {

        childList: true,

        subtree:true

};

$(function(){

        observer.observe(document.getElementsByTagName("body")[0],config);

});

function deleteResKusokote() {

        for(let i = 0; i< KUSOKOTE_LIST.length; i++) {

            let kusokote = KUSOKOTE_LIST[i];

            $("#resList").find("li").each(function(index) {

                let resId = parseInt($(this).attr("id").replace(/[^0-9]/g,""));

                let resObj = $(this);

                // 名前欄の文字列が非表示にしたいクソコテと一致した場合

                if($(resObj).find(".resname").text().match(new RegExp(kusokote))) {

                    // クソコテの外見を削除済レスと同じにする

                    deleteKusokote(resObj);

                    $("#resList").find(".reply").find("a[href='#res" + resId+"']").each(function(index) {

                        // 削除されたレスからの安価の親要素を取得

                        let parent = $(this).parent();

                        // 削除されたレスからの安価をremove()

                        $(this).remove();

                        // 削除されたレスからの安価をremove()後、他に安価がついていなければ安価の親要素自体をremove()

                        if(parent.find(".reslink").length==0) {

                            parent.remove();

                        }

                    });

                }

            });

        }

}

function deletePopupKusokote() {

        if ($("#popup").css("display") == "block") {

            let obj = $("#popup");

            for(let i = 0; i< KUSOKOTE_LIST.length; i++) {

                let kusokote = KUSOKOTE_LIST[i];

                // 名前欄の文字列が非表示にしたいクソコテと一致した場合

                if($(obj).find(".resname").text().match(new RegExp(kusokote))) {

                    deleteKusokote(obj);

                }

            }

        }

}

function deleteKusokote(target) {

        $(target).find(".resheader").find("button").remove();

        $(target).find(".resname").html("二次元好きの匿名さん");

        $(target).find(".resbody").addClass("disabled");

        $(target).find(".resbody").html("<p>このレスは削除されています</p>");

}

// 非表示にするクソコテリスト

// 「,」区切りで複数設定可能

// 正規表現も使える

const KUSOKOTE_LIST = [

        "獅子心深紅","無限射精おじさん","チンコプター\\(おじさんラジコン\\)"

        ,"クソコテ消すテスト3"

];