()
| 605 | |
| 606 | |
| 607 | function blockUsers_question() { |
| 608 | const blockUsers_question_ = (mutationsList, observer) => { |
| 609 | for (const mutation of mutationsList) { |
| 610 | for (const target of mutation.addedNodes) { |
| 611 | if (target.nodeType != 1) return |
| 612 | if (target.className === 'List-item' || target.className === 'Card AnswerCard') { |
| 613 | let item1 = target.querySelector('.ContentItem.AnswerItem'); |
| 614 | if (item1) { |
| 615 | menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 |
| 616 | if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 |
| 617 | console.log('已屏蔽:' + item1.dataset.zop) |
| 618 | target.hidden = true; |
| 619 | } |
| 620 | }) |
| 621 | } |
| 622 | } |
| 623 | } |
| 624 | } |
| 625 | }; |
| 626 | |
| 627 | const blockUsers_question_answer_ = (mutationsList, observer) => { |
| 628 | for (const mutation of mutationsList) { |
| 629 | for (const target of mutation.addedNodes) { |
| 630 | if (target.nodeType != 1) return |
| 631 | target.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ |
| 632 | let item1 = item.querySelector('.ContentItem.AnswerItem'); |
| 633 | if (item1) { |
| 634 | menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 |
| 635 | if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 |
| 636 | console.log('已屏蔽:' + item1.dataset.zop) |
| 637 | item.hidden = true; |
| 638 | } |
| 639 | }) |
| 640 | } |
| 641 | }) |
| 642 | } |
| 643 | } |
| 644 | }; |
| 645 | |
| 646 | if (location.pathname.indexOf('/answer/') > -1) { // 回答页(就是只有三个回答的页面) |
| 647 | const observer = new MutationObserver(blockUsers_question_answer_); |
| 648 | observer.observe(document, { childList: true, subtree: true }); |
| 649 | } else { // 问题页(可以显示所有回答的页面) |
| 650 | const observer = new MutationObserver(blockUsers_question_); |
| 651 | observer.observe(document, { childList: true, subtree: true }); |
| 652 | } |
| 653 | |
| 654 | // 针对的是打开网页后直接加载的前面几个回答(上面哪些是针对动态加载的回答) |
| 655 | document.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ |
| 656 | let item1 = item.querySelector('.ContentItem.AnswerItem'); |
| 657 | if (item1) { |
| 658 | menu_value('menu_customBlockUsers').forEach(function(item2){ // 遍历用户黑名单 |
| 659 | if (item1.dataset.zop.indexOf('authorName":"' + item2 + '",') > -1) { // 找到就删除该回答 |
| 660 | console.log('已屏蔽:' + item1.dataset.zop) |
| 661 | item.hidden = true; |
| 662 | } |
| 663 | }) |
| 664 | } |
no test coverage detected