Add Extra Tabs to Google Docs/Slides

Add extra tabs for Drawing and Erase by Lines to Google Docs and Slides

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Add Extra Tabs to Google Docs/Slides
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add extra tabs for Drawing and Erase by Lines to Google Docs and Slides
// @match        https://docs.google.com/document/d/*
// @match        https://docs.google.com/presentation/d/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    function addCustomTabs() {
        // Wait for the Google Docs/Slides page to fully load
        const interval = setInterval(() => {
            // Select the toolbar or relevant section where you want to add the tabs
            const toolbar = document.querySelector('.kix-appview-editor');

            if (toolbar) {
                // Clear the interval once the toolbar is found
                clearInterval(interval);

                // Create a container for the new tabs
                const customTabsContainer = document.createElement('div');
                customTabsContainer.className = 'custom-tabs-container';

                // Create the "Drawing" tab
                const drawingTab = document.createElement('div');
                drawingTab.className = 'custom-tab';
                drawingTab.textContent = 'Drawing';
                drawingTab.style.cursor = 'pointer';
                drawingTab.onclick = function() {
                    alert('Drawing tab clicked! Implement drawing functionality here.');
                };

                // Create the "Erase by Lines" tab
                const eraseTab = document.createElement('div');
                eraseTab.className = 'custom-tab';
                eraseTab.textContent = 'Erase by Lines';
                eraseTab.style.cursor = 'pointer';
                eraseTab.onclick = function() {
                    alert('Erase by Lines tab clicked! Implement erasing functionality here.');
                };

                // Append the new tabs to the container
                customTabsContainer.appendChild(drawingTab);
                customTabsContainer.appendChild(eraseTab);

                // Append the container to the toolbar
                toolbar.appendChild(customTabsContainer);

                // Add basic styling for the custom tabs
                const style = document.createElement('style');
                style.textContent = `
                    .custom-tabs-container {
                        display: flex;
                        gap: 10px;
                        padding: 10px;
                        background-color: #f1f1f1;
                    }
                    .custom-tab {
                        padding: 5px 10px;
                        background-color: #ddd;
                        border: 1px solid #ccc;
                        border-radius: 4px;
                    }
                    .custom-tab:hover {
                        background-color: #bbb;
                    }
                `;
                document.head.appendChild(style);
            }
        }, 1000); // Check every second
    }

    // Add custom tabs when the page loads
    window.addEventListener('load', addCustomTabs);
})();