您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add a toggle button to hide the Chat / Teams sidebar
当前为
// ==UserScript== // @name Microsoft Teams - Toggle Sidebar // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description Add a toggle button to hide the Chat / Teams sidebar // @author D365Fixes // @license MIT // @match https://teams.microsoft.com/v2/* // @icon https://www.google.com/s2/favicons?sz=64&domain=teams.microsoft.com // @run-at document-start // ==/UserScript== (function() { 'use strict'; const styles = ` .hide-sub-nav div[data-tid="experience-layout"] { --sub-nav-width: 0rem !important; } .hide-sub-nav div[data-tid="app-layout-area--sub-nav"] { opacity: 0; visibility: hidden; } div[data-tid="experience-layout"], div[data-tid^="app-layout-area"], div[data-tid="app-layout-area--sub-nav"] { transition: all .25s ease-in-out !important; transition-delay: unset !important; } #toggle-sidebar-btn { background-color: transparent; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; width: 30px; height: 30px; padding: 5px; margin-left: 10px; border: 0; cursor: pointer; } `; function injectStyles() { const styleElement = document.createElement('style'); styleElement.textContent = styles; document.head.appendChild(styleElement); } function addToggleButton() { var waitForTitlebarStartSlot = window.setInterval(function() { if (document.querySelectorAll('div[data-tid="titlebar-start-slot"]').length > 0) { console.log('[INFO] Titlebar Start Slot found'); window.clearInterval(waitForTitlebarStartSlot); const toggleButton = document.createElement('button'); toggleButton.id = 'toggle-sidebar-btn'; toggleButton.textContent = '◀️'; let sidebarOpen = true; toggleButton.addEventListener('click', function() { sidebarOpen = !sidebarOpen; toggleButton.textContent = sidebarOpen ? '◀️' : '▶️'; document.body.classList.toggle('hide-sub-nav'); }); document.querySelector('div[data-tid="titlebar-start-slot"]').appendChild(toggleButton); toggleButton.addEventListener('click', toggleSidebar); } }, 300); } function toggleSidebar() { const appDiv = document.getElementById('app'); if (appDiv) { appDiv.classList.toggle('hide-sub-nav'); } } document.addEventListener('DOMContentLoaded', function() { injectStyles(); addToggleButton(); }); })();