11// ==UserScript==
22// @name EarthMC 地图快速定位
3- // @version 2025.3.1
3+ // @version 2025.3.2
44// @updateURL https://cdn.jsdelivr.net/gh/AkarinLiu/EarthMC-Quick-Locate@master/main.user.js
55// @downloadURL https://cdn.jsdelivr.net/gh/AkarinLiu/EarthMC-Quick-Locate@master/main.user.js
66// @description 始终可用的坐标定位面板,支持参数覆盖和即时更新
4747 color: white;
4848 font-family: monospace;
4949 }
50- 。 coord-input:focus {
50+ . coord-input:focus {
5151 outline: 2px solid #00ff8866;
5252 }
53- 。 locator-button {
53+ . locator-button {
5454 background: linear-gradient(to right, #00ff88, #00ccff);
5555 border: none;
5656 color: #002211;
6060 font-weight: bold;
6161 transition: 0.2s;
6262 }
63- 。 locator-button:hover {
63+ . locator-button:hover {
6464 opacity: 0.9;
6565 transform: translateY(-1px);
6666 }
6767 ` ) ;
6868
69- const createPanel = ( ) => {
70- const panel = document . createElement ( 'div' ) ;
71- panel . className = 'earthmc-locator' ;
72-
73- const title = document . createElement ( 'h3' ) ;
74- title . className = 'locator-title' ;
75- title . innerHTML = '🗺 坐标定位' ; // 使用HTML实体代替表情符号
76-
77- const coordGroup = document . createElement ( 'div' ) ;
78- coordGroup . className = 'coord-group' ;
79-
80- const inputX = document . createElement ( 'input' ) ;
81- inputX . type = 'number' ;
82- inputX . className = 'coord-input' ;
83- inputX . id = 'mcX' ;
84- inputX . placeholder = 'X 坐标' ;
85- inputX . step = 'any' ;
86-
87- const inputZ = document . createElement ( 'input' ) ;
88- inputZ . type = 'number' ;
89- inputZ . className = 'coord-input' ;
90- inputZ . id = 'mcZ' ;
91- inputZ . placeholder = 'Z 坐标' ;
92- inputZ . step = 'any' ;
93-
94- const button = document . createElement ( 'button' ) ;
95- button . className = 'locator-button' ;
96- button . id = 'mcLocate' ;
97- button . textContent = '立即定位' ;
98-
99- // 层级组装
100- coordGroup . appendChild ( inputX ) ;
101- coordGroup . appendChild ( inputZ ) ;
102- panel . appendChild ( title ) ;
103- panel . appendChild ( coordGroup ) ;
104- panel . appendChild ( button ) ;
105-
106- return panel ;
107- } ;
108-
109- // 插入到页面
110- const panel = createPanel ( ) ;
111- document . body . appendChild ( panel ) ;
11269 // 创建定位面板
11370 const panel = document . createElement ( 'div' ) ;
11471 panel . className = 'earthmc-locator' ;
13996 world : searchParams . get ( 'world' ) || 'minecraft_overworld' ,
14097 zoom : searchParams . get ( 'zoom' ) || 0 ,
14198 x : document . getElementById ( 'mcX' ) . value || 0 ,
142- z : document . getElementById ( 'mcZ' ) 。 value || 0
99+ z : document . getElementById ( 'mcZ' ) . value || 0
143100 } ;
144101
145102 // 构建新URL
146103 const newURL = new URL ( baseURL ) ;
147104 newURL . search = new URLSearchParams ( preservedParams ) . toString ( ) ;
148-
105+
149106 // 避免重复跳转
150107 if ( newURL . href !== window . location . href ) {
151108 window . location . href = newURL . href ;
154111
155112 // 事件绑定
156113 document . getElementById ( 'mcLocate' ) . addEventListener ( 'click' , navigateToCoords ) ;
157-
114+
158115 // 回车键支持
159116 panel . querySelectorAll ( '.coord-input' ) . forEach ( input => {
160117 input . addEventListener ( 'keypress' , e => e . key === 'Enter' && navigateToCoords ( ) ) ;
161118 } ) ;
162119
163120 // 自动聚焦第一个输入框
164121 setTimeout ( ( ) => document . getElementById ( 'mcX' ) . focus ( ) , 500 ) ;
165- } ) ( ) ;
122+ } ) ( ) ;
0 commit comments