Greasy Fork

Greasy Fork is available in English.

Poe Optimize

1. Enlarges the chat input box. 2. Automatically moves the focus to the chat input box when the user types. 3. Sets the chatInput as the focus when the page is focused.

当前为 2023-04-21 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Poe Optimize
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  1. Enlarges the chat input box. 2. Automatically moves the focus to the chat input box when the user types. 3. Sets the chatInput as the focus when the page is focused.
// @author       Cursor & Mason
// @match        *://poe.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=poe.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    /** Function 1: Enlarges the chat input box */
    // Get all sections with class has prefix 'PageWithSidebarLayout_mainSection'
    const sections = document.querySelectorAll('[class^="PageWithSidebarLayout_mainSection"]');
    console.log(sections); // print sections for debug

    // Loop through each section and remove the width and max-width properties
    sections.forEach(section => {
        console.log('Processing element with class:', section.className);
        // make it important to prevent modify
        section.style.setProperty('width', 'unset', 'important');
        section.style.setProperty('max-width', 'unset', 'important');
    });

    /** Function 2: Automatically moves the focus to the chat input box when the user types or click button. (Has Problem with Chinese Input) */

    // Find the textarea element with class starting with ChatMessageInputView_textInput
    const chatInput = document.querySelector('textarea[class^="ChatMessageInputView_textInput"]');
    console.log(chatInput); // print chatInput for debug

    // Add an event listener to the document that listens for user input
    document.addEventListener('keypress', event => {
        // If the target of the input event is the chatInput element and it does not have focus, set focus to it
        if (!chatInput.matches(':focus')) {
            chatInput.focus();
        }
    });

    // Add an event listener to the document that listens for a click event on button elements
    document.addEventListener('click', event => {
        // If the clicked element is a button and the chatInput does not have focus, set focus to it
        if (event.target.tagName === 'BUTTON' && !chatInput.matches(':focus')) {
            chatInput.focus();
        }
    });


    /** Function 3: Sets the chatInput as the focus when the page is focused. */

    // Set the chatInput as the focus when the page is loaded
    window.addEventListener('focus', () => {
        chatInput.focus();
    });
})();