Tcafe Block User

try to take over the world!

当前为 2020-12-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Tcafe Block User
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  try to take over the world!
// @author       You
// @include      /tcafe2a.com/
// @require      http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

// 차단유저 ID
const IDs = ['testid1', 'testid2']
//const IDs = JSON.parse(GM_getValue("IDs"))

// 대상 node 선택
var target = document.querySelector('body')


// 감시자 인스턴스 만들기
var observer = new MutationObserver(function(mutations) {

    IDs.forEach(function (ID, index, array) {        
        let IDNode1 = document.querySelectorAll("div.user > a[onclick*=" + ID +"]")
        let IDNode2 = document.querySelectorAll("td > a[onclick*=" + ID +"]")

        if(IDNode2){
            for(var j=0; j < IDNode2.length; j++) {
                if (IDNode2[j].parentNode) {
                    console.log('게시글 번호  : ' + IDNode2[j].closest('tr').getAttribute('id') + ' -- ID : ' + ID)
                    $(IDNode2[j]).closest('tr').remove()
                }
            }
        }
        if(IDNode1 && /wr_id/.test(window.location.href)){
            for(var i=0; i < IDNode1.length; i++) {
                if (IDNode1[i].parentNode) {
                    console.log('코멘트 번호 : ' + IDNode1[i].closest('div.user').nextElementSibling.children[1].getAttribute('name') + ' -- ID : ' + ID)
                    $(IDNode1[i]).closest('div.box').remove()
                }
            }

        }
    })


})

// 감시자의 설정:
var config = { attributes: true, childList: true };

// 감시자 옵션 포함, 대상 노드에 전달
observer.observe(target, config);

// 차단 ID 저장
//GM_setValue("IDs", JSON.stringify(IDs))