zhihu_killer

知乎自动关闭登录框 智能识别登录状态

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         zhihu_killer
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  知乎自动关闭登录框 智能识别登录状态
// @author       wuuconix
// @match        https://*.zhihu.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict'

    const observer = new MutationObserver(() => {
        let avaterButton = document.querySelector(".Button.AppHeader-profileEntry.Button--plain")
        let closeButton = document.querySelector(".Button.Modal-closeButton.Button--plain")
        if (avaterButton) { //用户已经登录
            console.log("检测到你已登录,observer将自动关闭")
            observer.disconnect()
        } else if (closeButton) { //检查到弹出框
            closeButton.click()
            console.log("检测到登录框 已经为你自动关闭")
            observer.disconnect()
        }
    });

    observer.observe(document.body, { childList: true, });
})();