(comment)
| 1005 | |
| 1006 | function blockKeywords_comment() { |
| 1007 | function filterComment(comment) { |
| 1008 | let content = comment.querySelector('.CommentContent'); // 寻找评论文字所在元素 |
| 1009 | let text = content.textContent.toLowerCase(); // 全部转为小写(用来不区分大小写) |
| 1010 | content.querySelectorAll('img.sticker[alt]').forEach((img)=>{text += img.alt}) // 将评论中的表情添加到待遍历的评论文字中 |
| 1011 | |
| 1012 | let keywords = menu_value('menu_customBlockKeywords'); |
| 1013 | for (const keyword of keywords) { // 遍历关键词黑名单 |
| 1014 | if (keyword != '' && text.indexOf(keyword.toLowerCase()) > -1) { // 找到就删除该评论 |
| 1015 | console.log('已屏蔽评论:' + text); |
| 1016 | content.dataset.text = content.innerHTML |
| 1017 | content.onclick = (e)=>{if (e.target.dataset.text) {e.target.innerHTML = e.target.dataset.text;e.target.removeAttribute('data-text');}} |
| 1018 | content.textContent = '[该评论已屏蔽,可点击显示]'; |
| 1019 | } |
| 1020 | } |
| 1021 | } |
| 1022 | |
| 1023 | const callback = (mutationsList, observer) => { |
| 1024 | for (const mutation of mutationsList) { |
no test coverage detected