AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1794556
Accepted
alamar
alamar
Asked: 2023-07-07 18:28:34 +0800 CST2023-07-07 18:28:34 +0800 CST 2023-07-07 18:28:34 +0800 CST

使用本地 JS/CSS(例如 GreaseMonkey)使 GitHub 导航窗格始终可见

  • 772
赏金将在 5 天后到期。此问题的答案有资格获得+50声誉奖励。 alamar希望引起更多关注这个问题:
我希望有一个可运行的演练,使用选择的工具来完成此操作

GitHub 最近重新设计使其可用性大大降低,因为 2/3 的屏幕空间不再使用: GitHub 重新设计,空间浪费

如果您按汉堡菜单按钮,则会出现一个有用的侧边栏,但如果您单击其外部的任何位置,它就会消失: 带有侧边栏的 GitHub

我想使用一些 Chromium 插件来修改 GitHub 的 DOM/CSS 树,使这个侧边栏始终显示在所有页面上,如下面的 GIMPed 屏幕截图所示:

在此输入图像描述

如果有指示,我将不胜感激。我想将其重新定位到 DOM 树的不同位置并使其可见应该就足够了。

script
  • 1 1 个回答
  • 54 Views

1 个回答

  • Voted
  1. Best Answer
    ryelin
    2023-07-10T20:49:34+08:002023-07-10T20:49:34+08:00

    在点击汉堡包按钮之前,左侧边栏不会加载数据,而且我不知道该网站总体上是如何工作的,但我做了一些有点俗气的东西。

    // ==UserScript==
    // @name         New Userscript for superuser.com/questions/1794556
    // @namespace    http://tampermonkey.net/
    // @version      2
    // @description  superuser.com/questions/1794556
    // @match        https://github.com/*
    // ==/UserScript==
    
    (function() {
      'use strict';
    
      const css = `
    
      @media only screen and (min-width: 1300px) {
        body {
          overflow: auto !important;
        }
        .AppHeader-globalBar-start deferred-side-panel {
          transform: translatex(-15px);
        }
        .application-main main {
          max-width: calc(100vw - 320px - 2em);
          margin-left: auto;
        }
        deferred-side-panel > div > modal-dialog {
          position: absolute;
          top: 104px;
          left: 0px;
        }
        .Overlay-backdrop--side.Overlay-backdrop--placement-left.Overlay--hidden {
          display: flex !important;
          height: 100%;
          position: relative;
        }
        .AppHeader-globalBar-start .Overlay-backdrop--side {
          background-color: transparent;
        }
        .dashboard-sidebar,
        .AppHeader-globalBar-start deferred-side-panel > include-fragment > div[class] > modal-dialog,
        .AppHeader-globalBar-start deferred-side-panel > button[id],
        .AppHeader-globalBar-start deferred-side-panel > div[class] .Overlay-actionWrap {
          display: none !important;
        }
      }
    
      `;
    
      const styleElement = document.createElement('style');
    
      styleElement.textContent = css;
    
      document.head.appendChild(styleElement);
    
      function trigMenu() {
        setTimeout(function() {
          document.querySelector("deferred-side-panel > include-fragment > button[id]").click();
          document.querySelector(".Overlay-actionWrap > .close-button").click();
        }, 10);
      }
    
      const observer = new MutationObserver(function(mutationsList) {
        for (let mutation of mutationsList) {
          if (mutation.type === 'childList') {
            trigMenu();
            break;
          }
        }
      });
    
      observer.observe(document.body, { childList: true, subtree: true });
    
    })();
    

    代码所做的只是注入 CSS,使菜单栏显示在左侧,同时将其后面的元素移离菜单栏。然后,每当 DOM 发生变化时,它都会单击菜单按钮,以便动态数据将加载到侧边栏中。

    大部分工作都是在 CSS 中完成的。我没有探索每个页面是否存在明显的元素冲突,但到目前为止,在公共页面上似乎还不错。

    • 1

相关问题

  • 如何使用 Powershell 检查服务器是否具有固定 IP 地址?

  • bash 脚本:回显输出乱码且顺序错误

  • 如何在shell命令中的脚本中执行脚本

  • 如何编写远程监控和管理脚本

  • 更正脚本中的语法以附加到 root 的 .bashrc

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve