隐藏标题栏

隐藏网站的标题栏

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        隐藏标题栏
// @namespace   Violentmonkey Scripts
// @match       https://pychina.org/*
// @match       https://*.pychina.org/*
// @match       https://realpython.com/*
// @match       https://*.realpython.com/*
// @match       https://v2ex.com/*
// @match       https://*.v2ex.com/*
// @match       https://pycoders.com/*
// @match       https://*.pycoders.com/*
// @match       https://airflow.apache.org/*
// @match       https://*.airflow.apache.org/*
// @match       https://zhihu.com/*
// @match       https://*.zhihu.com/*
// @match       https://ddys.pro/*
// @grant       none
// @version     1.2
// @author      cichine
// @license     GPL3
// @run-at      document-start
// @description 隐藏网站的标题栏
// ==/UserScript==

(() => {
    const host = window.location.host;
    // const url = window.location.href;
    // const protocol = window.location.protocol;
    // const port = window.location.port;
    // const path = window.location.pathname;
    // const search = window.location.search;

    const styleMap = {
        "pychina.org": `
        /* 清除顶栏固定 */
        .navbar-fixed-top {
          top: unset;
          z-index: unset;
          position: unset;
        }
        body{
          padding-top: unset;
        }
    `,
        "realpython.com": `
        /* 清除顶栏固定 */
        .fixed-top {
          position: unset;
        }
        /* 隐藏右下角Help */
        #beacon-container {
          display: none;
        }
    `,
        "v2ex.com": `
        /* 隐藏背景 */
        #Wrapper {
          background-color: #fff !important;
          background-image: unset !important;
        }
        /* 隐藏头像 */
        .avatar {
          display: none;
        }`,
        "pycoders.com": `
        .bg-brand-gradient {
          background-image: unset !important;
        }
    `,
        "airflow.apache.org": `
        .navbar {
          position: unset;
          padding: unset;
        }
        .base-layout--button {
          display: none;
        }
        .base-layout {
          padding: unset;
        }
        .roadmap .td-sidebar {
          top: unset;
        }
    `,
        "zhihu.com": `
        .Sticky.is-fixed {
          position: unset;
        }
    `,
        "ddys.pro": `
        body {
          background-color: unset;
        }
        .hthb-notification {
          display: none;
        }
        .pagination a, .pagination span {
          background-color: unset;
          border: unset;
          color: unset;
        }
    `,
    };

    // 查找匹配的域名样式
    let s = "";
    for (const domain in styleMap) {
        if (host.endsWith(domain)) {
            s = styleMap[domain];
            break;
        }
    }
    console.log(`host: ${host}, style: ${s}`);

    const style = document.createElement("style");
    style.innerHTML = s;
    document.head.appendChild(style);
})();