MCPcopy Index your code
hub / github.com/XIU2/UserScript / blockKeywords_search

Function blockKeywords_search

Zhihu-Enhanced.user.js:977–1003  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

975
976
977 function blockKeywords_search() {
978 function blockKeywords_now() {
979 if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合]
980 document.querySelectorAll('.HotLanding-contentItem, .Card.SearchResult-Card[data-za-detail-view-path-module="AnswerItem"], .Card.SearchResult-Card[data-za-detail-view-path-module="PostItem"]').forEach(function(item1){blockKeywords_1(item1, 'a[data-za-detail-view-id]');})
981 }
982
983 setTimeout(blockKeywords_now, 2000);
984 window.addEventListener('urlchange', function(){
985 setTimeout(blockKeywords_now, 1000); // 网页 URL 变化后再次执行
986 })
987
988 const callback = (mutationsList, observer) => {
989 if (location.search.indexOf('type=content') === -1) return // 目前只支持搜索页的 [综合]
990 for (const mutation of mutationsList) {
991 for (const target of mutation.addedNodes) {
992 if (target.nodeType != 1) return
993 //console.log(target)
994 if (target.tagName === 'DIV' && target.className === '') {
995 let tt = target.querySelector('div[class="Card SearchResult-Card"][data-za-detail-view-path-module="AnswerItem"], div[class="Card SearchResult-Card"][data-za-detail-view-path-module="PostItem"]')
996 if (tt) {blockKeywords_1(target.childNodes[0], 'a[data-za-detail-view-id]');}
997 }
998 }
999 }
1000 };
1001 const observer = new MutationObserver(callback);
1002 observer.observe(document, { childList: true, subtree: true });
1003 }
1004
1005
1006 function blockKeywords_comment() {

Callers 1

blockKeywordsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected