油猴脚本:去除百度首页广告卡片推荐和二维码

问题描述:

最近打开百度首页,突然发现有了广告卡片推荐,如下情况所示:

解决方案:

  • 想要屏蔽显示的这个,不想被强制推广
  • 想到可以写个简单的油猴脚本,由于js只是会一点点,所以代码也比较low,不过可以达到自己想要的效果
  • 代码:
// ==UserScript==
// @name         隐藏百度首页的卡片
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.baidu.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
     document.getElementById("s-bottom-layer-hide-card-btn").remove();
     var news_content = document.getElementById("s_mancard_main");
     if (news_content){
        news_content.remove();
     }
    var qr_code = document.getElementById("qrcodeCon");
    if (qr_code){
       qr_code.remove();
    }

})();

最后效果如下:

猜你喜欢

转载自www.cnblogs.com/shiwanghualuo/p/12219648.html