|
97 | 97 | // @require https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js |
98 | 98 | // @match *://*/* |
99 | 99 | // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAABHNCSVQICAgIfAhkiAAABBdJREFUaIHtmluIVlUUx39pMup4Q1FrRi1CrMAaREUS75KlBhKKSGAKzkPRQ0lBPngjkIZeBMWHAccH8VIKJQTSIAgWVBQKglco7YYiitrYjONtjg/7G2bPPmt/nvOdtc8ndn5wQM/+77X+i73PnrPP/qCgoKCg4P/Bi8CGAHFfAj4JEDcTc4GodM1Ujt1aintcOW4mTtFT8GnFuAusuBGwSjF2xdQCdwlj7LwTt1kpbiYGAh30NtauEHe1EzMCtivEVeEEcXObM8bsFGIuyxhTjY3EzUXA4ArjNQmxHmSIp86zwH3iJvdWEGuoECcC9qs4VWQ3stGXU8b52hNnoppTJcYjG/05RYxJnhiHVZ0qcgjZ8OKE/X/x9J+t7lQJ3wj9lqDvUk/fNDOkKhxDNv5+mT5PAb97+r0d0qwG9nu1fV3DvKRIrPX0+SOwVzVOIxfQJGgHA20e/eocvKrwFnIBETDa0W716P7Ny6wWl5AL+cLS1Hs0EfBpnmY1eId4EfeBkZbmsKCJgHu5OlXkBr0Lsb+ITME/uo352tTjA3qKuATUWG1nkYv9M2ePqvSjZwV+17q/HP/ozsvZozpbgAvOvevIxR7N11oYRgLTrP+vxz+6r+TuLjBDkffNEdBSRV/B2IVcbCe9/1w9ETTgn8obq+grGEeQi70MPF1FX0FYiH90V5Y09Zht4hPBGeRi7VOKc8CM/K3pswb/6L7maB6r86NK6APcIl7oAWB6SdMPuGK1rcjfpg79MdNUGlmbz4X2N0OZ0lgkhmCOSF8FxgF1mDPdCR79JuCz0r/7Yz791Aq6m5gp/jdm43EO+J4qbi4WAD/ifz6lqwMY4MRpThnjH2Ad5lHIhT7Alx4zt/FvDHwvGGMw50aSvgv5UK278IYA9cU4KCQ/CyzBTOfhwPOY00Nb04aZ/hLuKF8HFgEvAGMxq/leIe8N4t/IVJkjJD3k0W5zdJvLxB2H+axj6/sKusVC/j3pSkjHN06yyx5dnaO7hdkplWMnyQr50NHdIdAo12CeGzvZex7tt44uyRfIsZhn1u5X79G6W8zXE1WQkjriC4hkaKqjuYZZ6JLgjnKrR/edo/soYfxUPEd8BKRpetzRrE2R4xmnb0TP66fNV47m4xQ5EjMC8zJgJ5ruaJY47TcryNPixDgmaH51NOUO6ipmIPHThIOOxv2ZUZrR7WY48VF+w2qvFdqDvYoeFZLNKrU1Ovc7MuRxPwWdsNpanbYuzIIXhFXEC76D2d795dzPspAME/I0In8T+yFDnkdS7uDavm4r5NqRII873YMwHv/7bfc1VynX1UfkCfHrXZFBwD7BQAfmtxpajAJOCnkuAPMrCZh1P1wDTMZsCv4DfsLsfLSZiNlItGOKvRggR0FBQcHjx0Ng/VhKUt8K3AAAAABJRU5ErkJggg== |
| 100 | +// @require https://cdn.jsdelivr.net/npm/mousetrap@1.6.5/mousetrap.min.js |
100 | 101 | // @compatible chrome |
101 | 102 | // @compatible firefox |
102 | 103 | // @compatible edge |
|
106 | 107 | // @compatible qq |
107 | 108 | // @compatible via |
108 | 109 | // @compatible brave |
109 | | -// @version 2025.03.19.0450 |
| 110 | +// @version 2026.3.10.1 |
110 | 111 | // @created 2025-03-18 07:13:13 |
111 | 112 | // @modified 2025-03-18 07:13:13 |
112 | 113 | // @downloadURL https://raw.githubusercontent.com/ChinaGodMan/UserScripts/main/web-clipper/web-clipper.user.js |
|
119 | 120 | * File Created: 2025/03/18,Tuesday 07:13:13 |
120 | 121 | * Author: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com) |
121 | 122 | * ----- |
122 | | - * Last Modified: 2025/03/19,Wednesday 04:50:15 |
| 123 | + * Last Modified: 2026/03/10,Tuesday 12:32:19 |
123 | 124 | * Modified By: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com) |
124 | 125 | * ----- |
125 | 126 | * License: MIT License |
|
172 | 173 | gui_github_owner: 'Please enter your GitHub username', |
173 | 174 | gui_save: 'Save', |
174 | 175 | gui_cancel: 'Cancel', |
| 176 | + hotkey: 'Press the hotkey you want to set.', |
| 177 | + hotkey1: 'Set hotkeys', |
175 | 178 | guide: ` |
176 | 179 | - Use **arrow keys** to select elements: |
177 | 180 | - Up: Select parent element |
|
202 | 205 | gui_github_owner: '请输入您的GitHub用户名', |
203 | 206 | gui_save: '保存', |
204 | 207 | gui_cancel: '取消', |
| 208 | + hotkey: '按下你想设置的热键', |
| 209 | + hotkey1: '设置热键', |
205 | 210 | guide: ` |
206 | 211 | - 使用**方向键**选择元素 |
207 | 212 | - 上:选择父元素 |
|
428 | 433 | .modal-title{margin:0 0 10px 0;font-size:20px;} |
429 | 434 | .modal-description{margin-bottom:20px;font-size:14px;color:#666;} |
430 | 435 | .modal-description a{color:#007bff;text-decoration:underline;} |
431 | | - .modal-close-btn {position: absolute;top: 10px;right: 10px;background-color: red;color: white;border: none;border-radius: 50%;width: 24px;height: 24px;font-size: 16px;cursor: pointer;display: flex;justify-content: center;align-items: center;line-height: 1;} |
432 | | - .modal-close-btn:hover {background-color: darkred;} |
| 436 | + .modal-close-btn{position:absolute;top:10px;right:10px;background-color:red;color:white;border:none;border-radius:50%;width:24px;height:24px;font-size:16px;cursor:pointer;display:flex;justify-content:center;align-items:center;line-height:1;} |
| 437 | + .modal-close-btn:hover{background-color:darkred;} |
433 | 438 | .gui-input{width:100%;padding:8px;border:1px solid #ccc;border-radius:4px;margin-bottom:20px;font-size:14px;} |
434 | 439 | #save-token{background-color:#28a745;color:white;border:none;padding:10px 20px;cursor:pointer;border-radius:4px;margin-right:10px;} |
435 | 440 | #cancel-token{background-color:#dc3545;color:white;border:none;padding:10px 20px;cursor:pointer;border-radius:4px;} |
436 | | - `) |
| 441 | + @media (prefers-color-scheme: dark){ |
| 442 | + .modal-overlay{background:rgba(0,0,0,0.7);} |
| 443 | + .modal-content{background:#1e1e1e;color:#e6e6e6;box-shadow:0 6px 20px rgba(0,0,0,0.6);} |
| 444 | + .modal-description{color:#aaa;} |
| 445 | + .modal-description a{color:#58a6ff;} |
| 446 | + .gui-input{background:#2a2a2a;color:#e6e6e6;border:1px solid #444;} |
| 447 | + #save-token{background-color:#238636;} |
| 448 | + #cancel-token{background-color:#b62324;} |
| 449 | +} |
| 450 | +`) |
437 | 451 | function showConfig() { |
438 | 452 | const modalHTML = ` |
439 | 453 | <div class="modal-overlay"> |
|
503 | 517 | return turndownMd |
504 | 518 | } |
505 | 519 |
|
| 520 | + // 热键设置 |
| 521 | + const STORAGE_KEY = 'web-clipper-hotkey' |
| 522 | + const DEFAULT_KEY = 'shift+alt+s' |
| 523 | + let currentHotkey = GM_getValue(STORAGE_KEY, DEFAULT_KEY) |
| 524 | + |
| 525 | + function bindHotkey(key) { |
| 526 | + Mousetrap.reset() |
| 527 | + Mousetrap.bind(key, function () { |
| 528 | + startSelecting() |
| 529 | + }) |
| 530 | + } |
| 531 | + |
| 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 | + } |
506 | 576 | // 预览 |
507 | 577 | function showMarkdownModal(markdown) { |
508 | 578 | var $modal = $(` |
|
733 | 803 | box-sizing: border-box; |
734 | 804 | overflow-y: auto; |
735 | 805 | } |
| 806 | + @media (prefers-color-scheme: dark){ |
| 807 | + .h2m-modal .h2m-preview{background:#1e1e1e;color:#e6e6e6;} |
| 808 | + } |
736 | 809 | .h2m-modal .h2m-buttons { |
737 | 810 | position: absolute; |
738 | 811 | bottom: 10px; |
|
0 commit comments