点进去没登陆就一个大大的登录框,尝试点击关闭按钮}});});const config = {childList: true。
并开始监控DOM变化document.addEventListener('DOMContentLoaded'。
我又不想登陆,。
() = {tryClickCloseButton();observer.observe(document.body,真烦就写了一个 [JavaScript] 纯文本查看 复制代码 // ==UserScript==// @name知乎自动关闭登录窗// @namespace // @version1.1// @description 尝试精确地关闭知乎登录窗口// @authoricescat// @match*://*.zhihu.com/*// @grantnone// @run-atdocument-body// ==/UserScript==(function() {'use strict';// 直接尝试点击关闭按钮const tryClickCloseButton = () = {const closeButton = document.querySelector('.Modal-closeButton');if (closeButton) {closeButton.click();}};// 使用MutationObserver实时关闭后续出现的登录窗const observer = new MutationObserver((mutations) = {mutations.forEach((mutation) = {if (mutation.addedNodes.length) {tryClickCloseButton(); // 如果出现新元素, 本帖最后由 sexcat 于 2024-2-27 16:24 编辑 一个知乎网站自动关闭登录窗的方案 有时候搜索东西搜到知乎了,subtree: true};// 在文档加载后立即执行关闭操作, config);});})(); 。
