如何用Tampermonkey永久隐藏Google Docs侧边栏切换按钮DIV
使用Tampermonkey永久隐藏Google Docs侧边栏切换按钮容器
步骤1:准备Tampermonkey
确保你已经在Chrome浏览器中安装了Tampermonkey扩展,未安装的话直接在Chrome应用商店搜索安装即可。
步骤2:创建用户脚本
- 点击浏览器右上角的Tampermonkey图标,选择「管理面板」进入脚本管理页面
- 点击左侧菜单栏的「+」按钮,创建新的空白脚本
- 删除页面中默认的模板代码,替换为以下脚本:
// ==UserScript== // @name 隐藏Google Docs侧边栏切换按钮 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 永久隐藏Google Docs右下角的侧边栏切换按钮容器,让文档居中显示 // @author 自定义你的名字 // @match https://docs.google.com/document/* // @grant none // ==/UserScript== (function() { 'use strict'; // 注入自定义CSS样式 const customStyle = document.createElement('style'); customStyle.textContent = ` .companion-collapser-button-container { display: none !important; } `; document.head.appendChild(customStyle); })();
步骤3:保存并生效
- 按下
Ctrl+S(Windows)或Cmd+S(Mac)保存脚本 - 刷新你的Google Docs文档页面,右下角的
<按钮容器就会被永久隐藏,文档也会自动居中显示
说明
@match字段确保脚本只会在Google Docs的文档页面生效,不会影响其他网站- 添加
!important是为了确保我们的CSS样式优先级高于页面原有样式,避免被覆盖
内容的提问来源于stack exchange,提问作者Bastiaan Quast
相关产品推荐
相关产品推荐

