您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
虎扑黑名单,隐藏拉黑的帖子
当前为
// ==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 0.0.1.20231209061935 // @namespace https://greasyfork.org/users/801480 // ==/UserScript== (function() { 'use strict'; window.onload = function() { 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'; } }); }); const hiddenUserListString = GM_getValue('hiddenUserList', ''); if (hiddenUserListString) { const hiddenUserList = hiddenUserListString.split(','); hiddenUserList.forEach(id => { const posts = document.querySelectorAll('.post-auth'); posts.forEach(post => { const postAuthor = post.querySelector('a').textContent; if (hiddenUserList.includes(postAuthor)) { post.closest('li').style.display = 'none'; } }); }); } GM_registerMenuCommand('移除黑名单', function() { const hiddenUserListString = GM_getValue('hiddenUserList', ''); if (hiddenUserListString) { const hiddenUserList = hiddenUserListString.split(','); const htmlList = hiddenUserList.map(user => "<div class='userItem'>" + user + "</div>").join(''); const html = "<div id='removeBlacklistDialog'><div class='title'>选择要移除的用户:</div><div id='userList'>" + htmlList + "</div><button id='closeButton'>关闭</button></div>"; const div = document.createElement('div'); div.innerHTML = html; document.body.appendChild(div); document.getElementById('closeButton').addEventListener('click', function() { div.remove(); }); const userList = document.getElementById('userList'); userList.addEventListener('click', function(event) { if (event.target.classList.contains('userItem')) { const userInput = event.target.textContent; const index = hiddenUserList.indexOf(userInput); hiddenUserList.splice(index, 1); const updatedHiddenUserList = hiddenUserList.join(','); GM_setValue('hiddenUserList', updatedHiddenUserList); userList.innerHTML = hiddenUserList.map(user => "<div class='userItem'>" + user + "</div>").join(''); } }); $('#removeBlacklistDialog').draggable(); } else { alert('当前黑名单为空'); } }); }; })(); // 添加样式 GM_addStyle(` #removeBlacklistDialog { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background-color: #f9f9f9; border: 1px solid #ccc; padding: 10px; text-align: center; } .title { font-weight: bold; font-size: 16px; margin-bottom: 10px; } #userList { margin-bottom: 20px; } #closeButton { position: absolute; bottom: 10px; right: 10px; } `);