// ==UserScript== // @name 虎扑黑名单 // @description 虎扑黑名单,隐藏拉黑的帖子 // @author Amamiya // @icon https://w1.hoopchina.com.cn/images/pc/old/favicon.ico // @match https://bbs.hupu.com/* // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_registerMenuCommand // @grant GM_addStyle // @require https://code.jquery.com/jquery-3.6.0.min.js // @require https://code.jquery.com/ui/1.12.1/jquery-ui.min.js // @license MIT // @version 1.2.0 // @namespace https://greasyfork.org/users/801480 // @downloadURL none // ==/UserScript== (function () { 'use strict'; window.onload = function () { var currentURL = window.location.href; const hiddenUserListString = GM_getValue('hiddenUserList', ''); const hiddenKeywordListString = GM_getValue('hiddenKeywordList', ''); if (!currentURL.includes('.html')) { if (hiddenUserListString||hiddenKeywordListString) { const hiddenUserList = hiddenUserListString.split(','); const hiddenKeywordList = hiddenKeywordListString.split(','); const posts = document.querySelectorAll('.bbs-sl-web-post-layout'); posts.forEach(post => { const postAuthor = post.children[2].textContent; const postTitle = post.children[0].textContent; if (hiddenUserListString&&hiddenUserList.includes(postAuthor)) { post.closest('li').style.display = 'none'; } if (hiddenKeywordListString&&hiddenKeywordList.some(item => postTitle.includes(item))) { post.closest('li').style.display = 'none'; } }); } const posts = document.querySelectorAll('.post-auth'); posts.forEach(post => { const span = document.createElement('span'); span.textContent = '黑'; span.style.cursor = 'pointer'; span.style.color = 'red'; span.style.marginRight = '10px'; if (post.firstChild) { post.insertBefore(span, post.firstChild); } else { post.appendChild(span); } span.addEventListener('click', function (event) { const id = event.target.parentElement.querySelector('a').textContent; if (confirm('是否确定将用户 "' + id + '" 拉入黑名单?')) { let hiddenUserList = GM_getValue('hiddenUserList', ''); if (hiddenUserList === '') { hiddenUserList = id; } else { hiddenUserList += ',' + id; } GM_setValue('hiddenUserList', hiddenUserList); event.target.closest('li').style.display = 'none'; } }); }); } else { const posts = document.querySelectorAll('.user-base-info'); posts.forEach(post => { const span = document.createElement('span'); span.textContent = '黑'; span.style.cursor = 'pointer'; span.style.color = 'red'; span.style.marginRight = '10px'; post.insertBefore(span, post.childNodes[1]); span.addEventListener('click', function (event) { const id = event.target.parentElement.querySelector('a').textContent; if (confirm('是否确定将用户 "' + id + '" 拉入黑名单?')) { let hiddenUserList = GM_getValue('hiddenUserList', ''); if (hiddenUserList === '') { hiddenUserList = id; } else { hiddenUserList += ',' + id; } GM_setValue('hiddenUserList', hiddenUserList); event.target.closest('.post-reply-list-wrapper').style.display = 'none'; } }); }); if (hiddenUserListString) { const hiddenUserList = hiddenUserListString.split(','); const posts = document.querySelectorAll('.user-base-info'); console.log(posts) posts.forEach(post => { const postAuthor = post.querySelector('a').textContent; if (hiddenUserList.includes(postAuthor)) { post.closest('.post-reply-list-wrapper').style.display = 'none'; } }); } } GM_registerMenuCommand('移除黑名单', function () { const hiddenUserListString = GM_getValue('hiddenUserList', ''); if (hiddenUserListString) { const hiddenUserList = hiddenUserListString.split(','); const htmlList = hiddenUserList.map(user => "