Greasy Fork

今日头条与建E网优化

2024/1/27 17:33:33

目前为 2024-02-28 提交的版本。查看 最新版本

// ==UserScript==
// @name        今日头条与建E网优化
// @namespace   Violentmonkey Scripts
// @match       https://www.toutiao.com/*
// @match       https://www.justeasy.cn/*
// @grant       none
// @version     0.0.8
// @author      YeSilin
// @license     MIT
// @grant       GM_addStyle
// @description 2024/1/27 17:33:33
// ==/UserScript==


// if(window.location.origin === "https://www.toutiao.com"){

// }


// 屏蔽今日头条置顶文章
if(window.location.href === "https://www.toutiao.com/"){
    let css = `
    .feed-card-wrapper.feed-card-article-wrapper.sticky-cell{
        display: none;
    }
    `
    GM_addStyle(css)
}


// 修复今日头条个人主页兼容 DarkReader
if(window.location.href.indexOf("https://www.toutiao.com/c/user/token/")>-1){
  // 删掉默认的白色背景
  // document.getElementsByClassName('profile-container')[0].style.background = "none";
  document.querySelector(".profile-container").style.background = "none";
  // 修改搜索框的背景颜色,即使改了也会被 DarkReader 修改成其他值以符合他的主题
  document.querySelector(".search>input").style.backgroundColor = "#eee";
}




// 等待网页内容加载完毕
window.addEventListener("load", function(){

  // 优化今日头条视频自动打开评论
  if(window.location.href.indexOf("https://www.toutiao.com/video/")>-1){
    document.querySelector(".video-action-button.comment").click()
  }

  // 优化今日头条文章自动打开评论
  if(window.location.href.indexOf("https://www.toutiao.com/article/")>-1){
    document.querySelector(".side-drawer-btn").click()
  }

  // 优化建E搜索去掉点燃背景
  if(window.location.href.indexOf("https://www.justeasy.cn")>-1){
    // 设定一个定时器以便能获取到元素
    let id = setInterval(function(){
      let hove_bgs = document.querySelectorAll(".hove_bg")
      // console.log("1111111111111")

      if(hove_bgs.length !== 0){
        for (let i=0; i<hove_bgs.length; i++){
          // console.log(hove_bgs[i])
          // 删除背景变暗
          hove_bgs[i].classList.remove("hove_bg"); // 删除一个或多个类名
        }

        // 清除定时器
        clearInterval(id)
      }

    }, 500);
  }

})