Last active
January 4, 2025 15:46
-
-
Save lunamoth/5df60b683199e940194e1c9420e0071f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 좌고우면 키보드 페이지 이동 유저스크립트 (최소화 버전) | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description 게시판 등 URL에 페이지 있을 시 좌우 방향키로 페이지 이동하게 해주는 유저스크립트 (최소화) | |
// @author Claude & Gemini | |
// @match *://*/* | |
// @grant none | |
// ==/UserScript== | |
addEventListener('keydown',e=>{ | |
const t=e.target; | |
if(t.tagName=='INPUT'||t.tagName=='TEXTAREA'||t.tagName=='SELECT'||t.isContentEditable||!e.key.startsWith('Arrow')||e.ctrlKey||e.metaKey)return; | |
e.preventDefault(); | |
const u=location.href,m=(u.match(/[?&](?:page|p)=(\d{1,4})|\/(?:page\/)?(\d{1,4})(?:\/|$)/i)||[])[0],d=e.key<'ArrowM'?-1:1; | |
if(/\/\d{10}/.test(u))return; | |
m?location.href=u.replace(m,m.replace(/\d+/,Math.max(1,+m.match(/\d+/)[0]+d))): | |
location.href=d>0?document.querySelector('a[rel="next"]')?.href:document.querySelector('a[rel="prev"]')?.href | |
},0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment