| 666 | } |
| 667 | |
| 668 | function blockUsers_search() { |
| 669 | function blockUsers_now() { |
| 670 | if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] |
| 671 | document.querySelectorAll('.Card.SearchResult-Card[data-za-detail-view-path-module="AnswerItem"], .Card.SearchResult-Card[data-za-detail-view-path-module="PostItem"]').forEach(function(item1){ |
| 672 | let item = item1.querySelector('.RichText.ztext.CopyrightRichText-richText b'); // 用户名所在元素 |
| 673 | if (item) { |
| 674 | for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单 |
| 675 | if (keyword != '' && item.textContent === keyword) { // 找到就删除该信息流 |
| 676 | console.log('已屏蔽:' + item.textContent); |
| 677 | item1.hidden = true; |
| 678 | break; |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | }) |
| 683 | } |
| 684 | |
| 685 | setTimeout(blockUsers_now, 2000); |
| 686 | window.addEventListener('urlchange', function(){ |
| 687 | setTimeout(blockUsers_now, 1000); // 网页 URL 变化后再次执行 |
| 688 | }) |
| 689 | |
| 690 | const callback = (mutationsList, observer) => { |
| 691 | if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合] |
| 692 | for (const mutation of mutationsList) { |
| 693 | for (const target of mutation.addedNodes) { |
| 694 | if (target.nodeType != 1) return |
| 695 | let item = target.querySelector('.Card.SearchResult-Card[data-za-detail-view-path-module="AnswerItem"] .RichText.ztext.CopyrightRichText-richText b, .Card.SearchResult-Card[data-za-detail-view-path-module="PostItem"] .RichText.ztext.CopyrightRichText-richText b'); |
| 696 | if (item) { |
| 697 | for (const keyword of menu_value('menu_customBlockUsers')) { // 遍历用户名黑名单 |
| 698 | if (keyword != '' && item.textContent === keyword) { // 找到就删除该信息流 |
| 699 | console.log('已屏蔽:' + item.textContent); |
| 700 | target.hidden = true; |
| 701 | break; |
| 702 | } |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | }; |
| 708 | const observer = new MutationObserver(callback); |
| 709 | observer.observe(document, { childList: true, subtree: true }); |
| 710 | } |
| 711 | |
| 712 | function blockUsers_comment() { |
| 713 | const callback = (mutationsList, observer) => { |