去除有道在线翻译页面样式

去除有道在线翻译最基础翻译功能外其他样式,保留最简洁的样式

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         去除有道在线翻译页面样式
// @namespace    小冰鸡
// @version      0.1
// @description  去除有道在线翻译最基础翻译功能外其他样式,保留最简洁的样式
// @author       小冰鸡
// @match        *://fanyi.youdao.com/*
// @match        *://*/*
// @grant        none
// @license MIT
// ==/UserScript==

;(function () {
  'use strict'
  function customFun() {
    let timer = setInterval(function () {
      let dom = document.querySelector('.tab-header')
      if (dom) {
        clearInterval(timer)

        dom.style.display = 'none'

        // 获取头部按钮列表,并且点击第一个
        let buttons = document.querySelectorAll('.tab-header .tab-item')
        buttons[0].click()

        // 要移除的dom类名列表
        let removeList = [
          '.ai-guide',
          '.sidebar-inner-container',
          '.header-content',
          '.top-banner-outer-container',
          '.banner-outer-container',
          '.document-upload-entrance-container',
          '.sidebar-container',
          '.dict-website-footer'
        ]
        removeList.forEach((domName) => {
          let dom = document.querySelector(domName)
          if (dom) dom.style.display = 'none'
        })
      }
      let dialog = document.querySelector('.pop-up-comp')
      if (dialog) {
        let ad = document.querySelector('.pop-up-comp .inner-content .ad')
        dialog.style.display = 'none'
      }
    }, 20)
  }
  customFun()
})()