Focus Chat

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

  1. // ==UserScript==
  2. // @name Focus Chat
  3. // @namespace https://greasyfork.org/users/281093
  4. // @match https://sketchful.io/
  5. // @grant none
  6. // @version 1.1
  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 (document.querySelector("#gameSettings").style.display !== "none") return;
  15. !isDrawing() && !e.ctrlKey && document.querySelector("#gameChatInput").focus();
  16. }
  17.  
  18. function isDrawing() {
  19. return document.querySelector("#gameTools").style.display !== "none" &&
  20. document.querySelector("body > div.game").style.display !== "none" &&
  21. document.activeElement !== document.querySelector("#gameChatInput");
  22. }