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

Function blockLowCount_

Zhihu-Enhanced.user.js:467–496  ·  view source on GitHub ↗
(className1, className2, menuUpvote, menuComment)

Source from the content-addressed store, hash-verified

465
466
467 function blockLowCount_(className1, className2, menuUpvote, menuComment) {
468 // 前几条因为是直接加载的,而不是动态插入网页的,所以需要单独判断
469 function blockLowCount_now() {
470 document.querySelectorAll(className1).forEach(function(item1){
471 console.log(item1)
472 blockLowCount_1(item1,menuUpvote,'upvote_num');
473 blockLowCount_1(item1,menuComment,'comment_num');
474 })
475 }
476
477 blockLowCount_now();
478 window.addEventListener('urlchange', function(){
479 setTimeout(blockLowCount_now, 1000); // 网页 URL 变化后再次执行
480 })
481
482 // 这个是监听网页插入事件,用来判断后续网页动态插入的元素
483 const callback = (mutationsList, observer) => {
484 for (const mutation of mutationsList) {
485 for (const target of mutation.addedNodes) {
486 if (target.nodeType != 1) return
487 if (target.className === className2) {
488 blockLowCount_1(target,menuUpvote,'upvote_num');
489 blockLowCount_1(target,menuComment,'comment_num');
490 }
491 }
492 }
493 };
494 const observer = new MutationObserver(callback);
495 observer.observe(document, { childList: true, subtree: true });
496 }
497
498
499 function blockLowCount_1(item, menu, type) {

Callers 1

blockLowCountFunction · 0.85

Calls 1

blockLowCount_nowFunction · 0.85

Tested by

no test coverage detected