CAI Left Panel&Voice Auto Hide

Hides left panel in chats&enables voice

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();
})();