自动关闭知乎登录(不可用)提示

自动关闭知乎自动弹出的登录(不可用)与注册(不可用)提示,仅仅用于关闭自动弹出的登录(不可用)提示,不干别的,未来也不会去干别的。

目前为 2023-05-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         自动关闭知乎登录(不可用)提示
// @version      1.3.0
// @author       F9y4ng
// @description  自动关闭知乎自动弹出的登录(不可用)与注册(不可用)提示,仅仅用于关闭自动弹出的登录(不可用)提示,不干别的,未来也不会去干别的。
// @namespace    https://github.com/F9y4ng/GreasyFork-Scripts/
// @icon         https://img.icons8.com/windows/48/zhihu.png
// @homepage     https://f9y4ng.github.io/GreasyFork-Scripts/
// @homepageURL  https://f9y4ng.github.io/GreasyFork-Scripts/
// @supportURL   https://github.com/F9y4ng/GreasyFork-Scripts/issues
// @match        *://*.zhihu.com/*
// @grant        none
// @compatible   Edge version>=105
// @compatible   Chrome version>=105
// @compatible   Firefox version>=103
// @compatible   Opera version>=91
// @compatible   Safari version>=15.4
// @license      GPL-3.0-only
// @copyright    2023, F9y4ng
// @run-at       document-start
// ==/UserScript==

/* jshint esversion: 11 */

(function () {
  "use strict";
  let nologin = true;
  const config = { childList: true, subtree: true };
  const callback = function (mutationsList, observer) {
    mutationsList.forEach(() => {
      if (nologin) {
        const loginNode = document.querySelector(`button[aria-label="关闭"][class~='Modal-closeButton']`);
        if (loginNode) {
          loginNode.click();
          nologin = false;
        }
      }
      const registFloatNode = document.querySelector(
        `body>div:not([class],[style],[id]):not(:has(.Modal-content)):not(:has(img[class~='Avatar'])) div[class^='css-']:has(svg[class*='css-'])`
      );
      if (registFloatNode) {
        registFloatNode.style.display = "none";
        registFloatNode.remove();
      }
    });
  };
  document.addEventListener("readystatechange", checkNoLogin);
  const observer = new MutationObserver(callback);
  observer.observe(document, config);
  function checkNoLogin() {
    if (document.readyState === "complete" && nologin) {
      nologin = false;
      document.removeEventListener("readystatechange", checkNoLogin);
    }
  }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址