n/chit-chatu/mjjmj · 41 分钟前
注册 登录
n/chit-chat · 41 分钟前 · 23 次浏览
u/mjjmj白银

让你的nl信息流更加简洁

// ==UserScript==
// @name         NodeLoc 收起右栏 · 正文铺平居中
// @namespace    https://www.nodeloc.com/
// @version      1.0.0
// @description  一键收起 NodeLoc 右侧信息栏(近期热门/广告/目录等),让帖子列表和正文铺开并居中显示;可随时恢复,状态自动记忆
// @author       mjjjjjjjjj
// @match        https://www.nodeloc.com/*
// @match        https://nodeloc.com/*
// @run-at       document-start
// @grant        none
// @noframes
// ==/UserScript==

(function () {
  'use strict';

  /* ======================= 可调参数 ======================= */

  const CONFIG = {
    // 刷新后默认是否收起右栏(true = 打开页面就收起;之后以下拉按钮的选择为准,记在 localStorage)
    defaultCollapsed: true,

    // 正文铺开后的最大宽度。'1200px' 之类为固定上限,居中显示;
    // 想完全铺满屏幕可改成 'none',想更窄可改成 '1080px'。
    mainMaxWidth: '1200px',

    // 是否显示右下角的「收起/展开右栏」悬浮按钮(false = 不显示,仅靠 Alt+S 切换)
    showButton: true,
  };

  /* ======================================================== */

  const CLASS = 'nl-aside-collapsed';
  const STORAGE_KEY = 'nodeloc-collapse-aside';
  const BTN_ID = 'nl-aside-toggle';

  const readSaved = () => {
    try {
      const v = localStorage.getItem(STORAGE_KEY);
      return v === null ? CONFIG.defaultCollapsed : v === '1';
    } catch (e) {
      return CONFIG.defaultCollapsed;
    }
  };
  const writeSaved = (v) => {
    try { localStorage.setItem(STORAGE_KEY, v ? '1' : '0'); } catch (e) { /* 隐私模式下忽略 */ }
  };

  let collapsed = readSaved();

  /* ---------- 样式 ---------- */

  const CSS = `
/* 当 html 带 .${CLASS} 时生效。变量 --nl-main-max 控制正文最大宽度。 */
html.${CLASS} { --nl-main-max: ${CONFIG.mainMaxWidth}; }

/* 1) 隐藏右侧信息栏:
      .cols > .aside      首页/节点页/帖子页/用户页等的右栏
      .split > .split-aside  我的节点/收藏/邀请/关于等页面的右栏
      .ob-page > .ob-aside   新人指引的右栏 */
html.${CLASS} :is(.cols > .aside, .split > .split-aside, .ob-page > .ob-aside) {
  display: none !important;
}

/* 2) 原本的两栏 grid(.cols,含帖子页的 .cols.reading)压成单栏 */
html.${CLASS} .cols {
  grid-template-columns: minmax(0, 1fr) !important;
  justify-content: stretch !important;
}

/* 2b) 列表视图下站点会把 .cols[data-wide] 改成 flex 横向排,这里改回单栏 grid */
html.${CLASS} :is(.page, .page > .node-page) > .cols[data-wide] {
  display: grid !important;
}

/* 3) 正文:铺开 + 居中。max-width 由 --nl-main-max 决定,两侧自动留白 */
html.${CLASS} .cols > .main {
  width: 100% !important;
  flex: none !important;
  max-width: var(--nl-main-max, 1200px) !important;
  margin-inline: auto !important;
}

/* 3b) 解除外层 1124px 的限宽,把右栏让出来的空间真正给到正文 */
html.${CLASS} .page > :where(.cols, .node-page) {
  max-width: none;
}

/* 4) .split 版式的页面(我的节点 / 收藏 / 能量明细 / 邀请 / 关于 / 常见问题…) */
html.${CLASS} .split {
  justify-content: center !important;
}
html.${CLASS} .split > .split-main {
  flex: 1 1 100% !important;
  width: 100% !important;
  max-width: var(--nl-main-max, 1200px) !important;
  margin-inline: auto !important;
}
/* 说明/条款一类的文档页保持窄栏,长文别拉太宽 */
html.${CLASS} .doc-page .split-main {
  max-width: 860px !important;
}

/* 5) 新人指引 .ob-page */
html.${CLASS} .ob-page {
  max-width: none;
}
html.${CLASS} .ob-page > .ob-main {
  width: 100% !important;
  max-width: var(--nl-main-max, 1200px) !important;
  margin-inline: auto !important;
}

/* ---------- 右下角悬浮按钮 ---------- */
#${BTN_ID} {
  position: fixed;
  z-index: 2147483000;
  right: 20px;
  bottom: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line, #e3e6e4);
  border-radius: 999px;
  background: var(--panel, var(--surface, #fff));
  color: var(--ink, #0f1a1c);
  font: 600 13px/1 "IBM Plex Sans", "Noto Sans SC", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  opacity: 0.92;
  box-shadow: var(--shadow-pop, 0 6px 20px rgba(15, 26, 28, .18));
  transition: opacity .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#${BTN_ID}:hover { opacity: 1; }
#${BTN_ID}:active { transform: scale(.96); }
#${BTN_ID} svg { width: 16px; height: 16px; flex: none; }

/* 手机上站点右下角有发帖按钮,往上让一让 */
@media (max-width: 860px) {
  #${BTN_ID} { right: 14px; bottom: 88px; }
}
@media print {
  #${BTN_ID} { display: none !important; }
}
`;

  function injectStyle() {
    if (document.getElementById('nl-aside-style')) return;
    const parent = document.head || document.documentElement;
    if (!parent) return;
    const style = document.createElement('style');
    style.id = 'nl-aside-style';
    style.textContent = CSS;
    parent.appendChild(style);
  }

  /* ---------- 状态应用 ---------- */

  function applyState() {
    if (!document.documentElement) return;
    document.documentElement.classList.toggle(CLASS, collapsed);

    const btn = document.getElementById(BTN_ID);
    if (btn) {
      btn.setAttribute('aria-pressed', String(collapsed));
      btn.title = (collapsed ? '展开' : '收起') + '右侧信息栏(Alt+S)';
      const label = btn.querySelector('.nl-label');
      if (label) label.textContent = collapsed ? '展开右栏' : '收起右栏';
    }
  }

  function toggle() {
    collapsed = !collapsed;
    writeSaved(collapsed);
    applyState();
  }

  /* ---------- 悬浮按钮 ---------- */

  function mountButton() {
    if (!CONFIG.showButton) return;
    if (!document.body || document.getElementById(BTN_ID)) return;

    const btn = document.createElement('button');
    btn.type = 'button';
    btn.id = BTN_ID;
    btn.innerHTML =
      '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" ' +
      'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' +
      '<rect x="3" y="4" width="18" height="16" rx="2"></rect><path d="M15 4v16"></path></svg>' +
      '<span class="nl-label"></span>';
    btn.addEventListener('click', toggle);
    document.body.appendChild(btn);
    applyState();
  }

  /* ---------- 启动 ---------- */

  function init() {
    injectStyle();
    applyState();
  }

  if (document.documentElement) {
    init();
  } else {
    document.addEventListener('DOMContentLoaded', init, { once: true });
  }

  if (document.body) {
    mountButton();
  } else {
    document.addEventListener('DOMContentLoaded', mountButton, { once: true });
  }

  // 快捷键:Alt+S 切换
  document.addEventListener('keydown', function (e) {
    if (e.altKey && !e.ctrlKey && !e.metaKey && (e.code === 'KeyS' || (e.key || '').toLowerCase() === 's')) {
      e.preventDefault();
      toggle();
    }
  });

  // 来回切换页面(含站点内部的局部刷新)时保持状态
  window.addEventListener('pageshow', applyState);
})();

0
2
登录后参与讨论。

2 条回复

排序
  1. mjjmj 白银 楼主 40 分钟前
    
    // ==UserScript==
    
    // @name         NodeLoc 收起右栏 · 正文铺平居中
    
    // @namespace    https://www.nodeloc.com/
    
    // @version      1.1.0
    
    // @description  一键收起 NodeLoc 右侧信息栏(近期热门/广告/目录等),让帖子列表和正文铺开并居中显示;可随时恢复,状态自动记忆
    
    // @author       mjjjjjjjj
    
    // @match        https://www.nodeloc.com/\*
    
    // @match        https://nodeloc.com/\*
    
    // @run-at       document-start
    
    // @grant        none
    
    // @noframes
    
    // ==/UserScript==
    
    (function () {
    
    'use strict';
    
    /\* ======================= 可调参数 ======================= \*/
    
    const CONFIG = {
    
    // 刷新后默认是否收起右栏(true = 打开页面就收起;之后以按钮的选择为准,记在 localStorage)
    
    defaultCollapsed: true,
    
    // 正文铺开后的最大宽度。'1200px' 之类为固定上限,居中显示;
    
    // 想完全铺满屏幕可改成 'none',想更窄可改成 '1080px'。
    
    mainMaxWidth: '1200px',
    
    // 是否在顶栏右侧显示小图标按钮(false = 不显示,仅靠 Alt+S 切换)
    
    showButton: true,
    
    };
    
    /\* ======================================================== \*/
    
    const CLASS = 'nl-aside-collapsed';
    
    const STORAGE_KEY = 'nodeloc-collapse-aside';
    
    const BTN_ID = 'nl-aside-toggle';
    
    const readSaved = () => {
    
    try {
    
    const v = localStorage.getItem(STORAGE_KEY);
    
    return v === null ? CONFIG.defaultCollapsed : v === '1';
    
    } catch (e) {
    
    return CONFIG.defaultCollapsed;
    
    }
    
    };
    
    const writeSaved = (v) => {
    
    try { localStorage.setItem(STORAGE_KEY, v ? '1' : '0'); } catch (e) { /\* 隐私模式下忽略 \*/ }
    
    };
    
    let collapsed = readSaved();
    
    /\* ---------- 样式 ---------- \*/
    
    const CSS = \`
    
    /\* 当 html 带 .${CLASS} 时生效。变量 --nl-main-max 控制正文最大宽度。 \*/
    
    html.${CLASS} { --nl-main-max: ${CONFIG.mainMaxWidth}; }
    
    /\* 1) 隐藏右侧信息栏:
    
    .cols > .aside      首页/节点页/帖子页/用户页等的右栏
    
    .split > .split-aside  我的节点/收藏/邀请/关于等页面的右栏
    
    .ob-page > .ob-aside   新人指引的右栏 \*/
    
    html.${CLASS} :is(.cols > .aside, .split > .split-aside, .ob-page > .ob-aside) {
    
    display: none !important;
    
    }
    
    /\* 2) 原本的两栏 grid(.cols,含帖子页的 .cols.reading)压成单栏 \*/
    
    html.${CLASS} .cols {
    
    grid-template-columns: minmax(0, 1fr) !important;
    
    justify-content: stretch !important;
    
    }
    
    /\* 2b) 列表视图下站点会把 .cols\[data-wide\] 改成 flex 横向排,这里改回单栏 grid \*/
    
    html.${CLASS} :is(.page, .page > .node-page) > .cols\[data-wide\] {
    
    display: grid !important;
    
    }
    
    /\* 3) 正文:铺开 + 居中。max-width 由 --nl-main-max 决定,两侧自动留白 \*/
    
    html.${CLASS} .cols > .main {
    
    width: 100% !important;
    
    flex: none !important;
    
    max-width: var(--nl-main-max, 1200px) !important;
    
    margin-inline: auto !important;
    
    }
    
    /\* 3b) 解除外层 1124px 的限宽,把右栏让出来的空间真正给到正文 \*/
    
    html.${CLASS} .page > :where(.cols, .node-page) {
    
    max-width: none;
    
    }
    
    /\* 4) .split 版式的页面(我的节点 / 收藏 / 能量明细 / 邀请 / 关于 / 常见问题…) \*/
    
    html.${CLASS} .split {
    
    justify-content: center !important;
    
    }
    
    html.${CLASS} .split > .split-main {
    
    flex: 1 1 100% !important;
    
    width: 100% !important;
    
    max-width: var(--nl-main-max, 1200px) !important;
    
    margin-inline: auto !important;
    
    }
    
    /\* 说明/条款一类的文档页保持窄栏,长文别拉太宽 \*/
    
    html.${CLASS} .doc-page .split-main {
    
    max-width: 860px !important;
    
    }
    
    /\* 5) 新人指引 .ob-page \*/
    
    html.${CLASS} .ob-page {
    
    max-width: none;
    
    }
    
    html.${CLASS} .ob-page > .ob-main {
    
    width: 100% !important;
    
    max-width: var(--nl-main-max, 1200px) !important;
    
    margin-inline: auto !important;
    
    }
    
    /\* ---------- 顶栏右侧的小图标按钮 ---------- \*/
    
    #${BTN_ID} {
    
    display: inline-flex;
    
    flex: none;
    
    align-items: center;
    
    justify-content: center;
    
    width: 32px;
    
    height: 32px;
    
    margin: 0 2px;
    
    padding: 0;
    
    border: 0;
    
    border-radius: 8px;
    
    background: transparent;
    
    color: var(--muted, #6b7774);
    
    cursor: pointer;
    
    -webkit-tap-highlight-color: transparent;
    
    user-select: none;
    
    transition: background-color .15s ease, color .15s ease;
    
    }
    
    #${BTN_ID}:hover {
    
    background: var(--hover, rgba(15, 26, 28, .06));
    
    color: var(--ink, #0f1a1c);
    
    }
    
    #${BTN_ID}\[aria-pressed="true"\] {
    
    background: var(--fill, rgba(15, 26, 28, .05));
    
    color: var(--ink, #0f1a1c);
    
    }
    
    #${BTN_ID} svg { width: 18px; height: 18px; flex: none; }
    
    /\* 顶栏找不到操作区时退回悬浮在右上角(少量页面) \*/
    
    #${BTN_ID}.nl-float {
    
    position: fixed;
    
    z-index: 2147483000;
    
    top: 72px;
    
    right: 14px;
    
    width: 34px;
    
    height: 34px;
    
    border: 1px solid var(--line, #e3e6e4);
    
    border-radius: 999px;
    
    background: var(--panel, var(--surface, #fff));
    
    box-shadow: 0 2px 10px rgba(15, 26, 28, .12);
    
    }
    
    /\* 手机上站点本来就没有右栏,按钮不出现,省得挤顶栏 \*/
    
    @media (max-width: 860px) {
    
    #${BTN_ID} { display: none !important; }
    
    }
    
    @media print {
    
    #${BTN_ID} { display: none !important; }
    
    }
    
    \`;
    
    function injectStyle() {
    
    if (document.getElementById('nl-aside-style')) return;
    
    const parent = document.head || document.documentElement;
    
    if (!parent) return;
    
    const style = document.createElement('style');
    
    style.id = 'nl-aside-style';
    
    style.textContent = CSS;
    
    parent.appendChild(style);
    
    }
    
    /\* ---------- 状态应用 ---------- \*/
    
    function applyState() {
    
    if (!document.documentElement) return;
    
    document.documentElement.classList.toggle(CLASS, collapsed);
    
    const btn = document.getElementById(BTN_ID);
    
    if (btn) {
    
    btn.setAttribute('aria-pressed', String(collapsed));
    
    btn.title = (collapsed ? '展开' : '收起') + '右侧信息栏(Alt+S)';
    
    btn.setAttribute('aria-label', (collapsed ? '展开' : '收起') + '右侧信息栏');
    
    }
    
    }
    
    function toggle() {
    
    collapsed = !collapsed;
    
    writeSaved(collapsed);
    
    applyState();
    
    }
    
    /\* ---------- 顶栏按钮 ---------- \*/
    
    function mountButton() {
    
    if (!CONFIG.showButton) return;
    
    if (!document.body || document.getElementById(BTN_ID)) return;
    
    const btn = document.createElement('button');
    
    btn.type = 'button';
    
    btn.id = BTN_ID;
    
    btn.innerHTML =
    
    '\<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" ' +
    
    'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">' +
    
    '\<rect x="3" y="4" width="18" height="16" rx="2">\</rect>\<path d="M15 4v16">\</path>\</svg>';
    
    btn.addEventListener('click', toggle);
    
    // 插在发帖按钮左边;登录/未登录、不同页面都在同一个位置
    
    const actions = document.querySelector('.top-actions');
    
    if (actions) {
    
    const anchor = actions.querySelector(
    
    '.btn, .top-post, a\[href$="/new"\], \[data-action="compose"\], \[data-action="new-topic"\]'
    
    );
    
    if (anchor) {
    
    actions.insertBefore(btn, anchor);
    
    } else {
    
    actions.appendChild(btn);
    
    }
    
    } else {
    
    btn.classList.add('nl-float');
    
    document.body.appendChild(btn);
    
    }
    
    applyState();
    
    }
    
    /\* ---------- 启动 ---------- \*/
    
    function init() {
    
    injectStyle();
    
    applyState();
    
    }
    
    if (document.documentElement) {
    
    init();
    
    } else {
    
    document.addEventListener('DOMContentLoaded', init, { once: true });
    
    }
    
    if (document.body) {
    
    mountButton();
    
    } else {
    
    document.addEventListener('DOMContentLoaded', mountButton, { once: true });
    
    }
    
    // 快捷键:Alt+S 切换
    
    document.addEventListener('keydown', function (e) {
    
    if (e.altKey && !e.ctrlKey && !e.metaKey && (e.code === 'KeyS' || (e.key || '').toLowerCase() === 's')) {
    
    e.preventDefault();
    
    toggle();
    
    }
    
    });
    
    // 来回切换页面(含站点内部的局部刷新)时保持状态
    
    window.addEventListener('pageshow', applyState);
    
    })();
    
    

    更新

    0
  2. Yang-iyu 白银 34 分钟前

    好用,但是似乎直接复制会有问题。我让GPT改了一版:

    // ==UserScript==
    // @name         NodeLoc 收起右栏 · 正文铺平居中
    // @namespace    https://www.nodeloc.com/
    // @version      1.1.0
    // @description  一键收起 NodeLoc 右侧信息栏(近期热门/广告/目录等),让帖子列表和正文铺开并居中显示;可随时恢复,状态自动记忆
    // @author       mjjjjjjjj
    // @match        https://www.nodeloc.com/*
    // @match        https://nodeloc.com/*
    // @run-at       document-start
    // @grant        none
    // @noframes
    // ==/UserScript==
    
    (function () {
        'use strict';
    
        const CONFIG = {
            defaultCollapsed: true,
            mainMaxWidth: '1200px',
            showButton: true,
        };
    
        const CLASS = 'nl-aside-collapsed';
        const STORAGE_KEY = 'nodeloc-collapse-aside';
        const BTN_ID = 'nl-aside-toggle';
    
        const readSaved = () => {
            try {
                const v = localStorage.getItem(STORAGE_KEY);
                return v === null ? CONFIG.defaultCollapsed : v === '1';
            } catch (e) {
                return CONFIG.defaultCollapsed;
            }
        };
    
        const writeSaved = (v) => {
            try {
                localStorage.setItem(STORAGE_KEY, v ? '1' : '0');
            } catch (e) {}
        };
    
        let collapsed = readSaved();
    
        const CSS = `
    html.${CLASS} {
        --nl-main-max: ${CONFIG.mainMaxWidth};
    }
    
    /* 隐藏右侧栏 */
    html.${CLASS} :is(
        .cols > .aside,
        .split > .split-aside,
        .ob-page > .ob-aside
    ) {
        display: none !important;
    }
    
    /* 两栏变单栏 */
    html.${CLASS} .cols {
        grid-template-columns: minmax(0, 1fr) !important;
        justify-content: stretch !important;
    }
    
    html.${CLASS} :is(.page, .page > .node-page) > .cols[data-wide] {
        display: grid !important;
    }
    
    /* 主内容宽度 */
    html.${CLASS} .cols > .main {
        width: 100% !important;
        flex: none !important;
        max-width: var(--nl-main-max, 1200px) !important;
        margin-inline: auto !important;
    }
    
    html.${CLASS} .page > :where(.cols, .node-page) {
        max-width: none !important;
    }
    
    /* split 布局页面 */
    html.${CLASS} .split {
        justify-content: center !important;
    }
    
    html.${CLASS} .split > .split-main {
        flex: 1 1 100% !important;
        width: 100% !important;
        max-width: var(--nl-main-max, 1200px) !important;
        margin-inline: auto !important;
    }
    
    html.${CLASS} .doc-page .split-main {
        max-width: 860px !important;
    }
    
    /* ob-page */
    html.${CLASS} .ob-page {
        max-width: none !important;
    }
    
    html.${CLASS} .ob-page > .ob-main {
        width: 100% !important;
        max-width: var(--nl-main-max, 1200px) !important;
        margin-inline: auto !important;
    }
    
    /* 按钮 */
    #${BTN_ID} {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        margin: 0 2px;
        padding: 0;
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--muted, #6b7774);
        cursor: pointer;
        user-select: none;
        transition: background-color .15s ease, color .15s ease;
    }
    
    #${BTN_ID}:hover {
        background: var(--hover, rgba(15,26,28,.06));
        color: var(--ink, #0f1a1c);
    }
    
    #${BTN_ID}[aria-pressed="true"] {
        background: var(--fill, rgba(15,26,28,.05));
        color: var(--ink, #0f1a1c);
    }
    
    #${BTN_ID} svg {
        width: 18px;
        height: 18px;
    }
    
    #${BTN_ID}.nl-float {
        position: fixed;
        z-index: 2147483000;
        top: 72px;
        right: 14px;
        width: 34px;
        height: 34px;
        border: 1px solid var(--line, #e3e6e4);
        border-radius: 999px;
        background: var(--panel, #fff);
        box-shadow: 0 2px 10px rgba(15,26,28,.12);
    }
    
    @media (max-width: 860px) {
        #${BTN_ID} {
            display: none !important;
        }
    }
    
    @media print {
        #${BTN_ID} {
            display: none !important;
        }
    }
    `;
    
        function injectStyle() {
            if (document.getElementById('nl-aside-style')) return;
    
            const style = document.createElement('style');
            style.id = 'nl-aside-style';
            style.textContent = CSS;
    
            (document.head || document.documentElement).appendChild(style);
        }
    
        function applyState() {
            document.documentElement.classList.toggle(CLASS, collapsed);
    
            const btn = document.getElementById(BTN_ID);
    
            if (btn) {
                btn.setAttribute('aria-pressed', String(collapsed));
                btn.title =
                    (collapsed ? '展开' : '收起') +
                    '右侧信息栏(Alt+S)';
            }
        }
    
        function toggle() {
            collapsed = !collapsed;
            writeSaved(collapsed);
            applyState();
        }
    
        function mountButton() {
            if (!CONFIG.showButton) return;
            if (document.getElementById(BTN_ID)) return;
    
            const btn = document.createElement('button');
            btn.type = 'button';
            btn.id = BTN_ID;
    
            btn.innerHTML = `
    <svg viewBox="0 0 24 24"
         fill="none"
         stroke="currentColor"
         stroke-width="1.75"
         stroke-linecap="round"
         stroke-linejoin="round">
        <rect x="3" y="4" width="18" height="16" rx="2"></rect>
        <path d="M15 4v16"></path>
    </svg>`;
    
            btn.addEventListener('click', toggle);
    
            const actions = document.querySelector('.top-actions');
    
            if (actions) {
                const anchor = actions.querySelector(
                    '.btn, .top-post, a[href$="/new"], [data-action="compose"], [data-action="new-topic"]'
                );
    
                if (anchor) {
                    actions.insertBefore(btn, anchor);
                } else {
                    actions.appendChild(btn);
                }
            } else {
                btn.classList.add('nl-float');
                document.body.appendChild(btn);
            }
    
            applyState();
        }
    
        function init() {
            injectStyle();
            applyState();
        }
    
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', () => {
                init();
                mountButton();
            });
        } else {
            init();
            mountButton();
        }
    
        document.addEventListener('keydown', function (e) {
            if (
                e.altKey &&
                !e.ctrlKey &&
                !e.metaKey &&
                (
                    e.code === 'KeyS' ||
                    (e.key || '').toLowerCase() === 's'
                )
            ) {
                e.preventDefault();
                toggle();
            }
        });
    
        window.addEventListener('pageshow', applyState);
    })();
    
    0