()
| 532 | bindHotkey(currentHotkey) |
| 533 | GM_registerMenuCommand(translate.hotkey1, openHotkeyUI) |
| 534 | function openHotkeyUI() { |
| 535 | if (document.getElementById('hotkey-overlay')) return |
| 536 | const overlay = document.createElement('div') |
| 537 | overlay.id = 'hotkey-overlay' |
| 538 | overlay.className = 'modal-overlay' |
| 539 | overlay.innerHTML = ` |
| 540 | <div class="modal-content"> |
| 541 | <button class="modal-close-btn" id="close-hotkey">×</button> |
| 542 | <h2 class="modal-title">${translate.hotkey}</h2> |
| 543 | <input id="hotkey-input"class="gui-input"value="${currentHotkey}"placeholder="${translate.hotkey}"> |
| 544 | <button id="save-token">${translate.gui_save}</button> |
| 545 | <button id="cancel-token">${translate.gui_cancel}</button> |
| 546 | </div> |
| 547 | ` |
| 548 | document.body.appendChild(overlay) |
| 549 | |
| 550 | const input = document.getElementById('hotkey-input') |
| 551 | input.focus() |
| 552 | input.addEventListener('keydown', function (e) { |
| 553 | e.preventDefault() |
| 554 | let keys = [] |
| 555 | if (e.ctrlKey) keys.push('ctrl') |
| 556 | if (e.shiftKey) keys.push('shift') |
| 557 | if (e.altKey) keys.push('alt') |
| 558 | let key = e.key.toLowerCase() |
| 559 | if (!['shift', 'ctrl', 'alt'].includes(key)) { |
| 560 | keys.push(key) |
| 561 | } |
| 562 | input.value = keys.join('+') |
| 563 | }) |
| 564 | document.getElementById('save-token').onclick = function () { |
| 565 | let key = input.value |
| 566 | if (!key) return |
| 567 | GM_setValue(STORAGE_KEY, key) |
| 568 | bindHotkey(key) |
| 569 | overlay.remove() |
| 570 | } |
| 571 | document.getElementById('cancel-token').onclick = |
| 572 | document.getElementById('close-hotkey').onclick = function () { |
| 573 | overlay.remove() |
| 574 | } |
| 575 | } |
| 576 | // 预览 |
| 577 | function showMarkdownModal(markdown) { |
| 578 | var $modal = $(` |
nothing calls this directly
no test coverage detected