// ==UserScript== // @name 단축키로 게시판 이동하기 // @version 0.1 // @description 원하는 게시판으로 단축키로 이동합니다. // @match *://damoang.net/* // @exclude *://damoang.net/*write* // @exclude *://damoang.net/plugin/editor/* // @grant none // ==/UserScript== (function() { 'use strict'; // 단축키와 이동할 페이지의 매핑 const shortcuts = { 'F': 'https://damoang.net/free', // 예시: F 키를 누르면 https://damoang.net/free로 이동 'J': 'https://damoang.net/economy', 'L': 'https://damoang.net/tutorial', 'Q': 'https://damoang.net/qa', 'I': 'https://damoang.net/gallery', 'N': 'https://damoang.net/new', // 다른 단축키와 이동할 페이지를 추가하려면 아래와 같이 추가하십시오. // 'A': 'https://damoang.net/another_page', // 'B': 'https://damoang.net/yet_another_page', // ... }; // 입력 요소인지 확인하는 함수 function isInputElement(element) { return ['INPUT', 'TEXTAREA', 'SELECT'].includes(element.tagName); } // 특정 키 조합이 사용되었는지 확인하는 함수 function isKeyCombination(event) { return event.ctrlKey || event.shiftKey || event.altKey; } // 키 다운 이벤트를 처리하는 함수 function handleKeyPress(event) { if (isInputElement(event.target) || isKeyCombination(event)) { return; // 입력 요소에 포커스가 있는 경우나 특정 키 조합이 사용된 경우 동작하지 않습니다. } const key = event.key.toUpperCase(); // 대문자로 변환하여 일관된 처리를 합니다. if (shortcuts[key]) { window.location.href = shortcuts[key]; // 해당 키에 매핑된 페이지로 이동합니다. } } // 키 다운 이벤트를 감지하여 처리합니다. window.addEventListener('keydown', handleKeyPress); })();