油猴-知乎自动关闭登录弹窗,自动跳转链接

// ==UserScript==
// @name         知乎-关闭登录-自动跳转链接
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       wwmin
// @match        https://*.zhihu.com/*
// @icon         https://static.zhihu.com/heifetz/favicon.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    closeLoginModal();
    var ci = setInterval(()=>{
        closeLoginModal();
    },200);
    setTimeout(()=>{
        clearInterval(ci);
    },3000);
    function closeLoginModal(){
        var btn = document.querySelector("Button.Modal-closeButton");
        if(btn){
            btn.click();
            clearInterval(ci);
        }
    }
    continueVisit();
    var vi = setInterval(()=>{
        continueVisit();
    },200);
    setTimeout(()=>{
        clearInterval(vi);
    },3000);
    function continueVisit(){
        var a = document.querySelector("a.button");
        if(a && a.innerText === "继续访问"){
            a.click();
            clearInterval(vi);
        }
    }
})();
posted @ 2022-03-01 11:23  lwlcode  阅读(648)  评论(0编辑  收藏  举报