百度首页自定义导航-> 取消默认推荐

2023/7/30 14:32:53

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        百度首页自定义导航-> 取消默认推荐
// @namespace   Violentmonkey Scripts
// @match       https://www.baidu.com/
// @grant       none
// @version     1.3.1
// @author      liuml
// @license MIT
// @description 2023/7/30 14:32:53
// ==/UserScript==

// 等待页面加载完成后执行代码
window.onload = function() {
     // 获取 s_xmancard_news_new 节点
  const xmancardNode = document.querySelector("#s_xmancard_news_new");

  // 检查是否找到 s_xmancard_news_new 节点
  if (xmancardNode) {
    // 将 s_xmancard_news_new 节点的样式设置为隐藏
    xmancardNode.style.display = "none";
    console.log("已隐藏 s_xmancard_news_new 节点");
  } else {
    console.log("未找到 s_xmancard_news_new 节点");
  }
const searchButton = document.querySelector("#s_menu_mine");

  // 模拟点击搜索按钮
  if (searchButton) {
    searchButton.click();
    console.log("已模拟点击我的关注");
  } else {
    console.log("未找到我的关注元素");
  }

};