Focus Chat

Focuses the chat when you type if you aren't drawing

当前为 2020-06-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Focus Chat
  3. // @namespace https://greasyfork.org/users/281093
  4. // @match https://sketchful.io/
  5. // @grant none
  6. // @version 1.0
  7. // @author Bell
  8. // @description Focuses the chat when you type if you aren't drawing
  9. // ==/UserScript==
  10.  
  11. document.addEventListener("keydown", focusChat, false);
  12.  
  13. function focusChat(e) {
  14. if (!isDrawing() && !e.ctrlKey) {
  15. document.querySelector("#gameChatInput").focus();
  16. }
  17. }
  18.  
  19. function isDrawing() {
  20. return document.querySelector("#gameTools").style.display !== "none" &&
  21. document.querySelector("body > div.game").style.display !== "none" &&
  22. document.activeElement !== document.querySelector("#gameChatInput");
  23. }