TikTok - Hide Menu Section

Hide Menu Section on TikTok for a cleaner view

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        TikTok - Hide Menu Section
// @description Hide Menu Section on TikTok for a cleaner view
// @version  1.0
// @grant    none
// @include	*://tiktok.com/*
// @include	*://*.tiktok.com/*
// @license     MIT
// @author      @guerrerohgp
// @namespace   https://greasyfork.org/users/1594918
// ==/UserScript==
(function() {
  const CONTAINER_SELECTOR = '[class*="-DivSideNavContainer"]';
  const BTN_ID = 'custom-collapse-toggle';

  function injectToggleButton() {
    const container = document.querySelector(CONTAINER_SELECTOR);
    
    // Prevent duplicate buttons
    if (!container || document.getElementById(BTN_ID)) return;

    const btn = document.createElement('button');
    btn.id = BTN_ID;
    btn.innerHTML = '<span>✕</span> Hide';
    
    // Premium styling to make it look integrated and modern
    Object.assign(btn.style, {
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      gap: '10px',
      width: 'calc(100% - 20px)',
      margin: '10px auto',
      padding: '12px',
      background: 'linear-gradient(135deg, #6366f1 0%, #a855f7 100%)',
      color: 'white',
      border: 'none',
      borderRadius: '12px',
      fontFamily: 'Inter, system-ui, sans-serif',
      fontSize: '14px',
      fontWeight: '600',
      cursor: 'pointer',
      transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
      boxShadow: '0 4px 12px rgba(99, 102, 241, 0.3)',
      zIndex: '1000'
    });

    // Hover effects
    btn.onmouseenter = () => {
      btn.style.transform = 'translateY(-2px)';
      btn.style.boxShadow = '0 6px 16px rgba(99, 102, 241, 0.4)';
    };
    btn.onmouseleave = () => {
      btn.style.transform = 'translateY(0)';
      btn.style.boxShadow = '0 4px 12px rgba(99, 102, 241, 0.3)';
    };

    let isCollapsed = false;

    btn.onclick = (e) => {
      e.preventDefault();
      e.stopPropagation();
      isCollapsed = !isCollapsed;
      
      // Hide/Show all other elements inside the container
      Array.from(container.children).forEach(child => {
        if (child !== btn) {
          child.style.setProperty('display', isCollapsed ? 'none' : '', 'important');
        }
      });

      // Update button state
      if (isCollapsed) {
        btn.innerHTML = '<span>☰</span> Show Menu';
        btn.style.background = '#1e293b'; // Dark mode collapsed look
        btn.style.width = 'fit-content';
        btn.style.padding = '10px 20px';
      } else {
        btn.innerHTML = '<span>✕</span> Hide';
        btn.style.background = 'linear-gradient(135deg, #6366f1 0%, #a855f7 100%)';
        btn.style.width = 'calc(100% - 20px)';
        btn.style.padding = '12px';
      }
    };

    // Add to the top of the container
    container.prepend(btn);
  }

  // Run immediately and also watch for DOM changes (in case the menu re-renders)
  injectToggleButton();
  const observer = new MutationObserver(() => injectToggleButton());
  observer.observe(document.body, { childList: true, subtree: true });
})();