()
| 463 | } |
| 464 | // 添加屏蔽按钮 |
| 465 | function addBlockButton() { |
| 466 | document.querySelectorAll('[id^="favatar"]').forEach(function (item) { // 遍历所有帖子 |
| 467 | let usernameLink = item.querySelector('a[href^="space-uid"]'); |
| 468 | if (usernameLink) { |
| 469 | const username = usernameLink.textContent, avatar = item.querySelector('.avatar'); |
| 470 | if (avatar && !avatar.parentNode.querySelector('.XIU-block-button')) { |
| 471 | // 创建屏蔽按钮 |
| 472 | let blockButton = document.createElement('div'); |
| 473 | blockButton.className = 'XIU-block-button'; |
| 474 | blockButton.title = `屏蔽用户: ${username}`; |
| 475 | blockButton.textContent = '🚫'; |
| 476 | blockButton.style.cssText = 'position: absolute;margin: -8px 0px 0px 8px;padding: 0px 0.5px;top: 0px;right: 10px;background-color: #F26C4F;border-radius: 50%;cursor: pointer;z-index: 302;box-shadow: 0 2px 4px rgba(0,0,0,0.2);transition: all 0.3s ease;'; |
| 477 | |
| 478 | // 鼠标悬停效果 |
| 479 | if (!document.getElementById('XIU-block-style')) { |
| 480 | let blockStyle = document.createElement('style'); |
| 481 | blockStyle.id = 'XIU-block-style'; |
| 482 | document.documentElement.appendChild(blockStyle).textContent = '.XIU-block-button:hover{transform: scale(1.2);background-color: #ff6666;}' |
| 483 | } |
| 484 | |
| 485 | // 点击事件 |
| 486 | blockButton.addEventListener('click', function (e) { |
| 487 | e.preventDefault(); |
| 488 | e.stopPropagation(); |
| 489 | |
| 490 | if (confirm(`确定要将用户 "${username}" 添加到黑名单吗?\n添加后该用户发布的任何内容都会被屏蔽`)) { |
| 491 | let blockList = GM_getValue('menu_customBlockUsers') || []; |
| 492 | if (!blockList.includes(username)) { |
| 493 | blockList.push(username); |
| 494 | GM_setValue('menu_customBlockUsers', blockList); |
| 495 | GM_notification({ text: `已将用户 "${username}" 添加到黑名单!\n刷新页面后生效。`, timeout: 3000 }); |
| 496 | |
| 497 | // 立即隐藏当前用户的帖子 |
| 498 | let postElement = item.closest('[id^="post_"]'); |
| 499 | if (postElement) { |
| 500 | postElement.style.opacity = '0.5'; |
| 501 | postElement.style.transition = 'opacity 0.5s ease'; |
| 502 | setTimeout(() => { postElement.hidden = true; }, 500); |
| 503 | } |
| 504 | } else { |
| 505 | GM_notification({ text: `用户 "${username}" 已在黑名单中!`, timeout: 2000 }); |
| 506 | } |
| 507 | } |
| 508 | }); |
| 509 | |
| 510 | // 将按钮添加到头像旁边 |
| 511 | avatar.parentNode.style.position = 'relative'; |
| 512 | avatar.parentNode.appendChild(blockButton); |
| 513 | } |
| 514 | } |
| 515 | }); |
| 516 | } |
| 517 | // 屏蔽阅读权限 255 的帖子 |
| 518 | function delate255() { |
| 519 | if (!menu_value('menu_delate255')) return |
no outgoing calls
no test coverage detected