Greasy Fork

Greasy Fork is available in English.

居中谷歌搜索页面

居中谷歌搜索页面布局。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Center Google Search Page
// @name:zh-CN   居中谷歌搜索页面
// @name:zh-TW   居中谷歌搜索頁面
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Centers the layout of Google search page.
// @description:zh-CN  居中谷歌搜索页面布局。
// @description:zh-TW  居中谷歌搜索頁面佈局。
// @author       ChatGPT 3.5
// @match        https://www.google.com/search?*
// @grant        none
// @license MIT
// ==/UserScript==

// 参考:https://salmon853.substack.com/p/32f,为了不影响在笔记本屏幕上的体验,可以自行更改 min-width 参数。

(function() {
    'use strict';

    // Function to add custom CSS styles  // 添加自定义 CSS 样式的函数
    function addStyle(css) {
        const style = document.createElement('style');
        style.textContent = css;
        document.head.appendChild(style);
    }

    // Custom CSS styles  // 自定义 CSS 样式
    const customStyles = `
        @media (min-width: 1537px) {
            /* AI 搜索 */
            .GcKpu {
                display: flex
                justify-content: center;
            }

            body {
                max-width: max-content;
                margin-left: auto;
                margin-right: auto;
            }
        }
    `;

    // Apply custom styles  // 应用自定义样式
    addStyle(customStyles);
})();