| 1215 | |
| 1216 | // 屏蔽盐选内容 |
| 1217 | function blockYanXuan() { |
| 1218 | if (!menu_value('menu_blockYanXuan')) return |
| 1219 | const blockYanXuan_question = (mutationsList, observer) => { |
| 1220 | for (const mutation of mutationsList) { |
| 1221 | for (const target of mutation.addedNodes) { |
| 1222 | if (target.nodeType != 1) return |
| 1223 | if (target.className === 'List-item' || target.className === 'Card AnswerCard') { |
| 1224 | if (target.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { |
| 1225 | target.hidden = true; |
| 1226 | } |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | }; |
| 1231 | |
| 1232 | const blockYanXuan_question_answer = (mutationsList, observer) => { |
| 1233 | for (const mutation of mutationsList) { |
| 1234 | for (const target of mutation.addedNodes) { |
| 1235 | if (target.nodeType != 1) return |
| 1236 | target.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ |
| 1237 | if (item.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { |
| 1238 | item.hidden = true; |
| 1239 | } |
| 1240 | }) |
| 1241 | } |
| 1242 | } |
| 1243 | }; |
| 1244 | |
| 1245 | if (location.pathname.indexOf('/answer/') > -1) { // 回答页(就是只有三个回答的页面) |
| 1246 | const observer = new MutationObserver(blockYanXuan_question_answer); |
| 1247 | observer.observe(document, { childList: true, subtree: true }); |
| 1248 | } else { // 问题页(可以显示所有回答的页面) |
| 1249 | const observer = new MutationObserver(blockYanXuan_question); |
| 1250 | observer.observe(document, { childList: true, subtree: true }); |
| 1251 | } |
| 1252 | |
| 1253 | // 针对的是打开网页后直接加载的前面几个回答(上面哪些是针对动态加载的回答) |
| 1254 | document.querySelectorAll('.List-item, .Card.AnswerCard').forEach(function(item){ |
| 1255 | if (item.querySelector('.KfeCollection-AnswerTopCard-Container, .KfeCollection-PurchaseBtn')) { |
| 1256 | item.hidden = true; |
| 1257 | } |
| 1258 | }) |
| 1259 | } |
| 1260 | |
| 1261 | |
| 1262 | // 区分问题文章 |