Greasy Fork

Baidu/Google搜索界面优化(AC-baidu-重定向双列优化)

Baidu/Google搜索界面优化

当前为 2022-12-25 提交的版本,查看 最新版本

// ==UserScript==
// @name            Baidu/Google搜索界面优化(AC-baidu-重定向双列优化)
// @name:zh         Baidu/Google搜索界面优化(AC-baidu-重定向双列优化)
// @namespace       ouka2020
// @description     Baidu/Google搜索界面优化
// @description:zh  Baidu/Google搜索界面优化
// @author          Ouka2020
// @match           *://ipv6.baidu.com/*
// @match           *://www.baidu.com/*
// @match           *://www1.baidu.com/*
// @match           *://encrypted.google.com/search*
// @match           *://*.google.com/search*
// @match           *://*.google.com/webhp*
// @exclude         *://*.google.com/sorry*
// @exclude         *://zhidao.baidu.com/*
// @exclude         *://*.zhidao.baidu.com/*
// @grant           GM_addStyle
// @version         0.6.8
// @license         GPL-3.0-or-later
// ==/UserScript==

/* Created by TPMK(ver 1.0.0) at 2022/12/25 17:36:30 */

(function () {
  'use strict';

  const googleCss = "/* google\"\" */\n#main #cnt,\n#cnt #center_col,\n#cnt #foot {\n  width: 95vw !important;\n  margin: 2px 12px !important;\n}\n\ndiv.MjjYud,\ndiv.hlcw0c {\n  grid-template-columns: unset;\n  grid-template-areas: unset;\n}";

  const baiduCss = "/* baidu */\nbody #container.sam_newgrid #content_left {\n  width: 96vw;\n}";

  const googleScrollEventListener = () => {
    document.querySelectorAll("div.ULSxyf").forEach((it) => it.remove());
    document.querySelectorAll("div.exp-outline").forEach((it) => it.remove());
  };
  if (/google/.test(window.location.host)) {
    GM_addStyle(googleCss);
    document.querySelectorAll("div.ULSxyf").forEach((it) => it.remove());
    document.querySelectorAll("div.exp-outline").forEach((it) => it.remove());
    document.querySelectorAll("div.M8OgIe").forEach((it) => it.remove());
    document.querySelectorAll("div.TQc1id.hSOk2e.rhstc4").forEach((it) => it.remove());
    window.addEventListener("scroll", googleScrollEventListener);
    window.addEventListener("unload", () => window.removeEventListener("scroll", googleScrollEventListener));
  }
  if (/baidu/.test(window.location.host)) {
    GM_addStyle(baiduCss);
  }

})();