Greasy Fork

Greasy Fork is available in English.

🔥 持续更新 🔥 去除百度翻译页面中的多余广告和元素

去除百度翻译页面中的多余广告和元素。

// ==UserScript==
// @name         🔥 持续更新 🔥 去除百度翻译页面中的多余广告和元素
// @version      0.3.1
// @description  去除百度翻译页面中的多余广告和元素。
// @author       WengX
// @namespace    https://github.com/iwengx
// @supportURL   https://gist.github.com/iwengx/be2d30e6a9cb3cfa9dda53a8910e3b4c
// @match        *://fanyi.baidu.com/*
// @icon         https://img1.imgtp.com/2023/02/25/YCeeiEQ1.png
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==


(function() {
    'use strict';

    /** 旧版 百度翻译 */
    const purge_css = `
       #app-read,
       #transOtherRight,
       .footer,
       .extra-wrap,
       .op-trans-fb,
       .nav-dxy-logo,
       .nav-sort-btn,
       .new-icon-btn,
       .dictionary-tags,
       .note-expand-btn,
       .manual-trans-btn,
       .dictionary-bottom,
       .navigation-wrapper,
       .new-domain-wrapper:before,
       .file-icon,
       .ai-trans-btn
       {
           display: none !important;
       }
    `
    GM_addStyle(purge_css);

    /** 新版 百度翻译(貌似采用了 css in js 的方案,所以样式名称类似加密文本) */
    const purge_cssinjs = `
       .cfm52tbf,
       .jygLSCYa,
       .h5JHRvHF,
       .nhcoTCy6,
       .UMjeGiEI,
       .n_FWnYmI,
       .RAbZsoLs,
       .sF3Yx_p0,
       ._m6jE1Mj,
       .Hu5qsRSB,
       .ZqJhu4sT,
       .UzOvH9bK,
       .Q35HUe2H,
       .DzKgtddY
       {
           display: none !important;
       }
    `
    GM_addStyle(purge_cssinjs);

    /** 自定义样式 */
    const custom_css = `
        .trans-other-wrap-left-part { width: 100% !important; }
        #side-nav .nav-ol .nav-search-again,
        #side-nav .nav-item { font-weight: unset; }
        #side-nav .nav-item span { color: rgb(0 0 0 / 45%); }
    `
    GM_addStyle(custom_css);
})();