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

Function closeFloatingComments

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

Source from the content-addressed store, hash-verified

1417
1418// 快捷关闭悬浮评论(监听点击事件,点击网页两侧空白处)
1419function closeFloatingComments() {
1420 const closeFloatingCommentsModal = (mutationsList, observer) => {
1421 for (const mutation of mutationsList) {
1422 for (const target of mutation.addedNodes) {
1423 if (target.nodeType != 1) return
1424 let button = document.querySelector('button[aria-label="关闭"]');
1425 if (button) {button.parentElement.parentElement.onclick = function(event){if (event.target.parentElement == this) {button.click();}}}
1426 }
1427 }
1428 };
1429 const observer = new MutationObserver(closeFloatingCommentsModal);
1430 observer.observe(document, { childList: true, subtree: true });
1431}
1432
1433
1434// 监听 XMLHttpRequest 事件

Callers 1

startFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected