屏蔽百度热搜

以前的脚本发现不生效了
放在GitHub 地址 https://github.com/liulimingking/BlockBaiduToplist

效果

使用方法

新建文件夹把下方两个文件拷到txt,并分别改扩展名并命名为content.js和manifest.json

Chrome浏览器地址栏输入chrome://extensions/

打开开发者模式。

点击“加载已解压的扩展程序”按钮。

浏览并选择刚才新建出来的文件夹。

一旦选择了正确的文件夹,Chrome将会自动加载并启用这个扩展程序。

conetnt.js

const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
let mo = new MutationObserver(function () {
    //搜索页
	Array.from(document.querySelectorAll('div.opr-toplist1-table_544Ty'), item => { 
        item.style.display = "none"; 
    });
	//首页
    Array.from(document.querySelectorAll('ul.s-hotsearch-content'), item => { 
      item.style.display = "none"; 
  });
});
mo.observe(document.getElementById("wrapper"), { attributes: true, subtree: true, childList: true });
  

manifest.json

{
  "name": "屏蔽百度热搜",
  "manifest_version": 3,
  "version": "2.0",
  "description": "github@liulimingking",
  "content_scripts": [
    {
      "matches": ["https://www.baidu.com/*"],
      "js": ["content.js"]
    }
  ]
}
posted @ 2024-04-10 00:18  liv_vil  阅读(79)  评论(0)    收藏  举报