NGA Red List

从https://nga.178.com/read.php?tid=23821517就能看出,论坛上NT太多,但是NGA自带的拉黑人数上限又太低。所以参考V2EX的RedList也做一个NGA版。

目前為 2020-10-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         NGA Red List
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  从https://nga.178.com/read.php?tid=23821517就能看出,论坛上NT太多,但是NGA自带的拉黑人数上限又太低。所以参考V2EX的RedList也做一个NGA版。
// @author       nyanpasus
// @match        *://nga.178.com/*
// @match        *://bbs.nga.cn/*
// @match        *://ngabbs.com/*
// @grant        GM_getValue
// @grant        GM_setValue
// @run-at       document-end
// ==/UserScript==
/* jshint esversion: 6 */
(function() {
    'use strict';

    let profileUid;
    let listName = 'nga-red-list';
    let uidList = GM_getValue(listName, "");
    let redList = uidList.split(';');
    let url = document.URL;
    let path = location.pathname;
    let buttonName = 'redButton';

    setTimeout(function() {
        function redsb() {
            let uidList = GM_getValue(listName, "");
            let redList = uidList.split(';');
            if (redList.indexOf(profileUid) >= 0) {
                GM_setValue(listName, uidList.replace(';' + profileUid, ''));
            } else {
                GM_setValue(listName, uidList + ';' + profileUid);
            }
            document.getElementById(buttonName).innerText = GM_getValue(listName, '').split(';').indexOf(profileUid) >= 0 ? '[取消拉红]' : '[拉红对方]';
        }

        if (path.startsWith('/thread.php')) {
            let homeList = document.getElementsByClassName('author');
            let len = homeList.length;
            for (let index = 0; index < len; index++) {
                let uid = homeList[index].title.split(' ')[1];
                if (redList.indexOf(uid) >= 0) {
                    homeList[index].parentElement.previousElementSibling.style.cssText += "background-image:url(https://i.loli.net/2019/06/09/5cfbebdfd083a19907.png);background-size:contain;";
                    homeList[index].parentElement.style.cssText += "background-image:url(https://i.loli.net/2019/06/09/5cfbebdfd083a19907.png);background-size:contain;";
                }
            }
        } else if (path.startsWith('/read.php')) {
            let commentList = document.getElementsByName('uid');
            let len = commentList.length;
            for (let index = 0; index < len; index++) {
                let uid = commentList[index].innerText;
                if (redList.indexOf(uid) >= 0) {
                    commentList[index].parentElement.parentElement.parentElement.style.cssText += "background-image:url(https://i.loli.net/2019/06/09/5cfbebdfd083a19907.png);background-size:contain;";
                    commentList[index].parentElement.parentElement.parentElement.nextElementSibling.style.cssText += "background-image:url(https://i.loli.net/2019/06/09/5cfbebdfd083a19907.png);background-size:contain;";
                }
            }
        } else if (path.startsWith('/nuke.php')) {
            console.info("abc");
            profileUid = document.getElementsByClassName('info')[0].firstElementChild.lastElementChild.innerText.split(':')[1].trim();
            let buttonContainer = document.getElementsByClassName('actions')[0];
            let constructLi = document.createElement('li');
            constructLi.setAttribute('style','padding-right: 5px;');
            let constructSpan = document.createElement('span');
            let constructA = document.createElement('a');
            constructA.setAttribute('href','javascript:void(0)');
            constructA.setAttribute('id', buttonName);
            constructA.innerText = redList.indexOf(profileUid) >= 0 ? '[取消拉红]' : '[拉红对方]';
            let lastDiv = document.getElementsByClassName(' clear')[4];
            constructSpan.appendChild(constructA);
            constructLi.appendChild(constructSpan);
            buttonContainer.insertBefore(constructLi, lastDiv);
            document.getElementById(buttonName).onclick= redsb;
        }
    }, 1000);
})();