| 1417 | |
| 1418 | // 快捷关闭悬浮评论(监听点击事件,点击网页两侧空白处) |
| 1419 | function 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 事件 |