嗨皮漫畫 - 隐藏特定位置的 導覽列

隱藏除了頂部和底部以外的 導覽列

目前為 2024-04-25 提交的版本,檢視 最新版本

// ==UserScript==
// @version      0.8
// @name         嗨皮漫畫 - 隐藏特定位置的 導覽列
// @name:zh-TW   嗨皮漫畫 - 隐藏特定位置的 導覽列
// @name:zh-CN   嗨皮漫画 - 隐藏特定位置的 导航栏
// @name:en Happy Comics - Hide Specific Position AppBar
// @namespace    https://www.youtube.com/c/ScottDoha
// @description  隱藏除了頂部和底部以外的 導覽列
// @description:zh-cn 隐藏除了顶部和底部以外的 導覽列
// @description:en Hide AppBar except at the top and bottom of the page
// @author       Scott
// @match        *://m.happymh.com/reads/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 获取標題欄元素
    var header = document.querySelector('.MuiAppBar-root');

    // 定義一個函數,用於顯示或隱藏標題欄
    function toggleHeaderVisibility() {
        // 檢查是否在頁面頂部或底部
        var isAtTop = window.scrollY === 0;
        var isAtBottom = window.innerHeight + window.scrollY >= document.body.offsetHeight;

        // 如果不在頂部或底部,則隱藏標題欄,否則顯示
        if (!isAtTop && !isAtBottom) {
            header.style.display = 'none';
        } else {
            header.style.display = 'block';
        }
    }

    // 監聽滾動事件,以更新標題欄的可見性
    window.addEventListener('scroll', toggleHeaderVisibility);

    // 首次加載時調用函數以初始化標題欄的可見性
    toggleHeaderVisibility();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址