🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/08 23:56:27
🔄 下次更新时间:2026/01/09 00:56:27
手动刷新缓存

Google Calendar Sidebarizer

Hides everything but the calendar portion of the UI.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name       Google Calendar Sidebarizer
// @namespace  http://www.arthaey.com
// @version    1.0
// @description  Hides everything but the calendar portion of the UI.
// @match      http://www.google.com/calendar/*
// @match      https://www.google.com/calendar/*
// @match      http://calendar.google.com/*
// @match      https://calendar.google.com/*
//
// Backed up from http://userscripts.org/scripts/review/177182
// Last updated on 2013-12-04
// ==/UserScript==

// Google-controlled element IDs and CSS classes, subject to change without notice. :(
var ELEMENTS = {
    calendarContainer: { id: "mainbody" },
    calendar: { id: "scrolltimedeventswk" },
    extra: { id: "bdata" },
    oneBar: { id: "onegoogbar" },
    sideNav: { id: "nav" },
    topNav: { id: "vr-nav" },
    viewMenuContainer: { id: "topRightNavigation" } /* IE ಠ_ಠ */
};
var VIEW_OPTION_CLASS_NAME = "goog-imageless-button-collapse-right";

/******************************************************************************
 * SIDEBARIZE FUNCTIONS
 ******************************************************************************/

function sidebarize() {
    // Hide everything but the calendar itself.
    hideElement(ELEMENTS.oneBar);
    hideElement(ELEMENTS.extra);
    hideElement(ELEMENTS.sideNav);
    hideElement(ELEMENTS.topNav);
    
    // Show sidebarize links.
    showElement(ELEMENTS.actionsContainer);
    
    // Remove unwanted styles.
    var calendarContainer = ELEMENTS.calendarContainer;
    calendarContainer.originalMarginLeft = calendarContainer.node.style.marginLeft;
    calendarContainer.node.style.marginLeft = "0";
}

function unsidebarize() {
    // Hide sidebarize links
    hideElement(ELEMENTS.actionsContainer);
    
    // Show hidden elements.
    showElement(ELEMENTS.oneBar);
    showElement(ELEMENTS.extra);
    showElement(ELEMENTS.sideNav);
    showElement(ELEMENTS.topNav);
    
    // Restore original styles.
    var calendarContainer = ELEMENTS.calendarContainer;
    calendarContainer.node.style.marginLeft = calendarContainer.originalMarginLeft;
    ELEMENTS.calendar.node.style.overflowY = "scroll";
}

function addSidebarizeOption() {
    // Find the "Agenda" option, to copy.
    var viewMenu = ELEMENTS.viewMenuContainer.node.childNodes[0];
    if (!viewMenu) return;    
    var agendaOption = viewMenu.childNodes[5];
    if (!agendaOption) return;
    
    // Create "Sidebarize" option, copied from "Agenda".
    var sidebarizeOption = agendaOption.cloneNode(true);
    var optionText = sidebarizeOption.childNodes[0].childNodes[0].childNodes[0].childNodes[1]; // So ugly...
    if (!optionText) return;
    optionText.innerHTML = "Sidebarize";
    sidebarizeOption.onclick = sidebarize;
    
    // Update styles and add options to UI.
    agendaOption.className += " " + VIEW_OPTION_CLASS_NAME;
    viewMenu.appendChild(sidebarizeOption);
    addLinkBelowCalendar("Unsidebarize", unsidebarize);
    addLinkBelowCalendar("Toggle scrollbar", toggleScrollbar);
    addLinkBelowCalendar("Remove these links", hideActions);
}

function toggleScrollbar() {
    var cal = ELEMENTS.calendar.node;
    cal.style.overflowY = (cal.style.overflowY == "hidden") ? "scroll" : "hidden";
}

function hideActions() {
    if (confirm("If you remove these links, you will have to refresh the page to see them again.")) {
        hideElement(ELEMENTS.actionsContainer);
    }
}

/******************************************************************************
 * HELPER FUNCTIONS
 ******************************************************************************/

function hideElement(elementObj) {
    elementObj.node.style.display = "none";
}

function showElement(elementObj) {
    elementObj.node.style.display = "block";
}

function addLinkBelowCalendar(text, func) {
    var link = document.createElement("a");
    link.href = "#";
    link.innerHTML = text;
    link.onclick = func;
    link.style.paddingRight = "1em";
    
    if (!ELEMENTS.actionsContainer) {
        var div = document.createElement("div");        
        ELEMENTS.actionsContainer = {
            id: "sidebarizer-actions-container",
            node: div /* IE ಠ_ಠ */
        };
      ELEMENTS.calendarContainer.node.appendChild(div);
        hideElement(ELEMENTS.actionsContainer);
    }
    ELEMENTS.actionsContainer.node.appendChild(link);
}

function findElements() {
    var foundAllElements = true;
    for (var elementKey in ELEMENTS) {
        var element = ELEMENTS[elementKey];
        element.node = document.getElementById(element.id);
        if (!element.node) {
            foundAllElements = false;
        }
    }
    return foundAllElements;
}

/******************************************************************************
 * ENTRY POINT
 ******************************************************************************/

// Wait 1 second; things in the One Bar have to load before the script will work.
setTimeout(function() {
    if (findElements()) {
      addSidebarizeOption();
    }
}, 1000);