EnterToLogin

Press Enter to trigger a login-related button if no input is focused.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @license MIT
// @name         EnterToLogin
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Press Enter to trigger a login-related button if no input is focused.
// @author       aceitw
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // Utility: normalize text for matching (e.g. "Sign In" -> "signin")
  function normalize(text) {
    return text.toLowerCase().replace(/\s+/g, '');
  }

  // Utility: is element visible?
  function isVisible(el) {
    const rect = el.getBoundingClientRect();
    return rect.width > 0 && rect.height > 0 && window.getComputedStyle(el).visibility !== 'hidden';
  }

  // Utility: is likely a login button based on text
  function isLoginText(text) {
    const normalized = normalize(text);
    return /^(log(in)?|sign(in)?)$/.test(normalized);
  }

  document.addEventListener('keydown', function (e) {
    if (e.key !== 'Enter') return;

    const active = document.activeElement;
    const isTyping = active && (
      active.tagName === 'INPUT' ||
      active.tagName === 'TEXTAREA' ||
      active.isContentEditable
    );
    if (isTyping) return;

    const candidates = Array.from(document.querySelectorAll('button, input[type="submit"], a'));
    const loginBtn = candidates.find(el => {
      const text = el.innerText || el.value || '';
      return isVisible(el) && isLoginText(text);
    });

    if (loginBtn) {
      loginBtn.click();
      e.preventDefault();
    }
  });
})();