您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
d2l.ai添加隐藏侧栏按钮
当前为
// ==UserScript== // @name d2l.ai隐藏侧栏 // @namespace http://tampermonkey.net/ // @version 0.1 // @description d2l.ai添加隐藏侧栏按钮 // @author You // @match https://zh.d2l.ai/chapter_introduction/index.html // @icon https://www.google.com/s2/favicons?sz=64&domain=d2l.ai // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Your code here... // 获取元素 const drawer = document.querySelector('.mdl-layout__drawer'); const main = document.querySelector('.mdl-layout__content'); const doc = document.documentElement; // 创建按钮 const btn = document.createElement('button'); btn.classList.add('mdl-button', 'mdl-js-button', 'mdl-js-ripple-effect'); btn.textContent = '隐藏侧边'; // 按钮点击事件处理函数 function toggleDrawer() { if (drawer.style.display === 'none') { // 显示侧边栏 drawer.style.display = ''; main.style.marginLeft = '256px'; btn.textContent = '隐藏侧边'; doc.style.width = ''; } else { // 隐藏侧边栏 drawer.style.display = 'none'; main.style.marginLeft = '50px'; btn.textContent = '显示侧边'; doc.style.width = '100vw'; } } // 添加按钮到导航元素中 const nav = document.querySelector('.mdl-navigation'); nav.appendChild(btn); // 绑定按钮点击事件 btn.addEventListener('click', toggleDrawer); })();