居中谷歌搜索頁面

居中谷歌搜索頁面佈局。

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();