菜鸟公园
  • 编程技能
    • PHP
    • CPP
    • Golang
    • MySQL
    • 工具分享
  • 英语学习
  • 信文随笔
  • 关于本站
sign in/up

标签归档:油猴

2020-11-30 作者:菜鸟DJ 0
工具分享, 编程技能

让浏览器自动移除知乎的登录弹窗(已更新)

由于某些原因,我注销了知乎的账号。但是在网页的搜索中,会出现一些知乎的内容。当我点进去会发现,知乎会强制登录才能查看内容。以前会有一个关闭的按钮,最近关闭的按钮被去除了。

作为程序员,肯定不希望阅读体验这么差,所以用 油猴工具 制作了如下脚本,自动移除弹窗,并恢复页面的滚动条。

// ==FeHelperMonkey==
// @reminder        请不要删除这部分代码注释,这是FeHelper油猴脚本能正常工作的基本条件!当然,你可以按需修改这里的内容!
// @id              mf_1606719966367
// @name            关闭知乎登录
// @url-pattern     https://*.zhihu.com/question/*
// @enable          true
// @require-js      
// @auto-refresh    0
// @updated         2020-12-01 10:03:30
// ==/FeHelperMonkey==


// 在这里,可以随便写你的代码,并且,你的代码中
// 1. 可以进行页面上的所有DOM操作
// 2. 可以访问页面上原本已挂载的所有Js变量,比如页面上已经有了jQuery,你可以直接使用
// 3. 可以依赖注入一个第三方js脚本,然后在你的代码中直接使用,如:依赖jQuery后直接使用
// 4. 好了,你的代码可以这样写:
var toast = (content,time) => {
    return new Promise((resolve,reject) => {
      let elAlertMsg = document.querySelector("#fehelper_alertmsg");
      if (!elAlertMsg) {
          let elWrapper = document.createElement('div');
          elWrapper.innerHTML = '<div id="fehelper_alertmsg" width="100%" style="position:absolute;top:10px;left:50%;-webkit-transform:translateX(-50%);z-index:100">' +
              '<tb style="background:red;display:inline-block;color:white;text-align:center;' +
              'padding:10px 10px;margin:0 auto;font-size:20px;border-radius:8px;">' + content + '</tb></div>';
          elAlertMsg = elWrapper.childNodes[0];

        document.body.appendChild(elAlertMsg);
        // elAlertMsg = document.getElementById("fehelper_alertmsg");
        // elAlertMsg.style.left=(document.body.clientWidth-elAlertMsg.offsetWidth)/2+"px";
      } else {
          elAlertMsg.querySelector('p').innerHTML = content;
          elAlertMsg.style.display = 'block';
      }

        window.setTimeout(function () {
          elAlertMsg.style.display = 'none';
            resolve && resolve();
      }, time || 1000);
  });
};

(()=>{
  toast("【菜鸟公园】关闭知乎登录弹窗",2000).then(()=>{
    let a = document.getElementsByClassName('Modal-wrapper');
    for (i=0;i<a.length;i++){
      a[i].parentNode.removeChild(a[i]);
    }
    document.documentElement.style.overflow='visible';
  });
})();

js zhihu 弹窗 油猴 登录 知乎 脚本

1/1

天气

分类目录

热门文章

记一次和流氓软件战斗的过程0 comments
手机app https抓包步骤一揽0 comments
记一下RabblitMQ的安装和RPC的工作模式0 comments
聊一聊快排算法0 comments
MAC & WIN 平台效率工具清单0 comments
你真的会用MySQL里的max函数吗?0 comments
MySQL 分组之后如何取Top(N)?0 comments
B站代码解读 — LRUCache0 comments
解搜索二维矩阵题0 comments
解一道字符串变化题0 comments

微信公众号:菜鸟公园

微信公众号
微信公众号:菜鸟公园
隐私政策