您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
1. 扩大聊天框。2. 自动设置输入框焦点。
当前为
// ==UserScript== // @name Poe扩大聊天框,自动设置输入框焦点 // @name:en Poe Enlarge chat box And auto set focus to input box. // @name:zh-CN Poe扩大聊天框,自动设置输入框焦点 // @namespace http://tampermonkey.net/ // @version 0.6.4 // @description:en 1. Enlarge chat box. 2. Auto set focus to input box. // @description:zh-CN 1. 扩大聊天框。2. 自动设置输入框焦点。 // @author Cursor & Mason // @match *://poe.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=poe.com // @grant none // @license MIT // @description 1. Enlarges the chat 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. // ==/UserScript== (function () { 'use strict'; /** Function 1: Enlarges the chat box */ function enlargeChatBox() { console.log("enlargeChatBox!") // Get all sections with class has prefix 'PageWithSidebarLayout_mainSection' const sections = document.querySelectorAll('[class^="PageWithSidebarLayout_mainSection"]'); // Loop through each section and remove the width and max-width properties sections.forEach(section => { // make it important to prevent modify section.style.setProperty('width', 'unset', 'important'); section.style.setProperty('max-width', 'unset', 'important'); section.style.setProperty('min-width', '684px', 'important'); }); } // Call the function whenever needed enlargeChatBox(); /** 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(); }); /** Function 4: Enlarges the chat box on new pages */ const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'href') { enlargeChatBox(); } }); }); observer.observe(document.body, { attributes: true, subtree: true, attributeFilter: ['href'] }); })();