CAI Left Panel&Voice Auto Hide

Hides left panel in chats&enables voice

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CAI Left Panel&Voice Auto Hide
// @namespace    http://tampermonkey.net/
// @version      2024-11-30
// @description  Hides left panel in chats&enables voice
// @author       LuxTallis
// @match        https://character.ai/chat/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=character.ai
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to click the button with the selector button.text-sm
    function clickButtonTextSm() {
        const button = document.querySelector('button.text-sm');
        if (button) {
            button.click();
            console.log('Button with selector "button.text-sm" found and clicked.');
        } else {
            console.log('Button with selector "button.text-sm" not found yet. Trying again.');
            setTimeout(clickButtonTextSm, 1000); // Retry after 1 second
        }
    }

    // Function to click the button with the selector #chat-header > div:nth-child(2) > button:nth-child(1)
    function clickChatHeaderButton() {
        const button = document.querySelector('#chat-header > div:nth-child(2) > button:nth-child(1)');
        if (button) {
            button.click();
            console.log('Button with selector "#chat-header > div:nth-child(2) > button:nth-child(1)" found and clicked.');
        } else {
            console.log('Button with selector "#chat-header > div:nth-child(2) > button:nth-child(1)" not found yet. Trying again.');
            setTimeout(clickChatHeaderButton, 1000); // Retry after 1 second
        }
    }

    // Launch both functions in parallel
    clickButtonTextSm();
    clickChatHeaderButton();
})();