吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4488|回复: 46
收起左侧

[其他原创] 油猴脚本·自动关闭知乎登陆弹窗

  [复制链接]
sexcat 发表于 2024-2-27 14:05
本帖最后由 sexcat 于 2024-2-27 16:24 编辑

一个知乎网站自动关闭登录窗的方案
有时候搜索东西搜到知乎了,
点进去没登陆就一个大大的登录框。
我又不想登陆,真烦就写了一个
[JavaScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// ==UserScript==
// @name         知乎自动关闭登录窗
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  尝试精确地关闭知乎登录窗口
// @author       icescat
// @match        *://*.zhihu.com/*
// @grant        none
// @run-at       document-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(); // 如果出现新元素,尝试点击关闭按钮
            }
        });
    });
 
    const config = {
        childList: true,
        subtree: true
    };
 
    // 在文档加载后立即执行关闭操作,并开始监控DOM变化
    document.addEventListener('DOMContentLoaded', () => {
        tryClickCloseButton();
        observer.observe(document.body, config);
    });
})();

免费评分

参与人数 11吾爱币 +15 热心值 +10 收起 理由
szllw + 1 + 1 谢谢@Thanks!
zake + 1 + 1 谢谢@Thanks!
xiaojian40 + 1 + 1 用心讨论,共获提升!
w1608011442 + 1 用心讨论,共获提升!
战勇 + 1 + 1 谢谢@Thanks!
luanshils + 1 + 1 热心回复!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
Ricky_Xiao + 1 谢谢@Thanks!
shanzhanzhe + 1 + 1 谢谢@Thanks!
yaoshun3 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
WJF12321 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

RS水果 发表于 2024-2-27 15:26
本帖最后由 RS水果 于 2024-2-28 14:22 编辑

你这属于是杀鸡用牛刀了  操作CSS就够了

// ==UserScript==
// @name         屏蔽登录弹窗
// @namespace    URL
// @version      0.1
// @description  A brief summary to describe the script
// @author       Your name
// @match        https://*.zhihu.com/*
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

GM_addStyle(`
/* 屏蔽登录弹窗 */
.Modal-wrapper.undefined.Modal-enter-done{
  display: none !important;
}
/* 屏蔽右下角登录提示 */
.css-1wq6v87{
  display: none !important;
}
/* 解锁滚动条 */
html{
  overflow: unset !important;
}
/* 避免闪烁 */
.Modal-backdrop{
  background-color: unset !important;
}
`)

免费评分

参与人数 1热心值 +1 收起 理由
WJF12321 + 1 我很赞同!

查看全部评分

 楼主| sexcat 发表于 2024-2-28 09:29
top7777 发表于 2024-2-28 09:21
主登录窗口有效,右下角登录窗口无效。

右下角我试了好几种也不好怎么去掉,有空了再研究
yaoshun3 发表于 2024-2-27 15:40
头像被屏蔽
sparker351 发表于 2024-2-27 15:47
提示: 作者被禁止或删除 内容自动屏蔽
hs248613 发表于 2024-2-27 16:03
搞搞淘宝、京东、天猫吧,网页不登录查个东西都不行…………
liujg 发表于 2024-2-27 16:10
谷歌说,用户脚本无效
 楼主| sexcat 发表于 2024-2-27 16:22
EDGE用了没毛病,奇怪代码传上来自动给我加了好多字符,我重传一下
shanzhanzhe 发表于 2024-2-27 17:15
正好需要呢,谢谢!
sai609 发表于 2024-2-27 17:17
不得行,会不停跳转?
hxd97244 发表于 2024-2-27 17:27
hs248613 发表于 2024-2-27 16:03
搞搞淘宝、京东、天猫吧,网页不登录查个东西都不行…………

同样的需求,最烦随便找个东西,要登陆的这种。看都没看那,就要登陆,真的烦。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-4-15 19:56

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表