-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.user.js
More file actions
2195 lines (1914 loc) · 79.2 KB
/
script.user.js
File metadata and controls
2195 lines (1914 loc) · 79.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Linuxdo-share
// @namespace http://tampermonkey.net/
// @version 0.15.36
// @description 从linux do论坛页面获取文章的板块、标题、链接、标签和内容总结,并在标题旁添加复制按钮。支持设置界面配置。
// @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDY0IDY0Ij48cmVjdCB4PSIxOCIgeT0iMTQiIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOCIgcng9IjYiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRlNTk2OSIgc3Ryb2tlLXdpZHRoPSI0Ii8+PHJlY3QgeD0iMTIiIHk9IjIwIiB3aWR0aD0iMzAiIGhlaWdodD0iMzgiIHJ4PSI2IiBmaWxsPSJub25lIiBzdHJva2U9IiMxNjRkZTUiIHN0cm9rZS13aWR0aD0iNCIvPjwvc3ZnPg==
// @icon64 data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCIgdmlld0JveD0iMCAwIDY0IDY0Ij48cmVjdCB4PSIxOCIgeT0iMTQiIHdpZHRoPSIzMCIgaGVpZ2h0PSIzOCIgcng9IjYiIGZpbGw9Im5vbmUiIHN0cm9rZT0iIzRlNTk2OSIgc3Ryb2tlLXdpZHRoPSI0Ii8+PHJlY3QgeD0iMTIiIHk9IjIwIiB3aWR0aD0iMzAiIGhlaWdodD0iMzgiIHJ4PSI2IiBmaWxsPSJub25lIiBzdHJva2U9IiMxNjRkZTUiIHN0cm9rZS13aWR0aD0iNCIvPjwvc3ZnPg==
// @author @Loveyless https://github.com/Loveyless/linuxdo-share
// @match *://*.linux.do/*
// @match *://*.idcflare.com/*
// @updateURL https://raw.githubusercontent.com/Loveyless/linuxdo-share/main/script.user.js
// @downloadURL https://raw.githubusercontent.com/Loveyless/linuxdo-share/main/script.user.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_registerMenuCommand
// @run-at document-idle // 更可靠的运行时间,等待DOM和资源加载完成且浏览器空闲
// ==/UserScript==
(function () {
'use strict';
// #region 脚本配置与常量
// ==========================================================
/**
* @description 默认配置项,当油猴存储中没有对应值时使用。
*/
const DEFAULT_CONFIG = {
// 是否启用简洁模式:标题+摘要合并一段,隐藏作者/板块/标签,链接单独一行
COMPACT_MODE: false,
// 是否启用 AI 进行内容总结
USE_AI_FOR_SUMMARY: false,
// AI Key,如果 USE_AI_FOR_SUMMARY 为 true,则需要填写此项
API_KEY: '',
// API 地址 (OpenAI Compatible 格式,完整地址如 https://api.openai.com/v1/chat/completions)
API_BASE_URL: 'https://api.openai.com/v1/chat/completions',
// 模型名称
MODEL_NAME: 'gpt-4o-mini',
// 总结后的最大字符数
LOCAL_SUMMARY_MAX_CHARS: 90,
// 自定义总结 Prompt
CUSTOM_SUMMARY_PROMPT: `你是一个信息获取专家,可以精准的总结文章的精华内容和重点,请对以下文章内容进行归纳总结,回复不要有对我的问候语,或者(你好这是我的总结)(总结)等类似废话,直接返回你的总结,长度不超过{maxChars}个字符(或尽可能短,保持中文语义完整): {content}`,
// 文章复制模板
ARTICLE_COPY_TEMPLATE: [
`{{title}}`,
`@{{username}}-{{category}}/{{tags}}`,
``,
`{{summary}}`,
`{{link}}`,
].join('\n')
};
/**
* @description 脚本内部使用的常量配置
*/
const SCRIPT_CONSTANTS = {
// API 请求超时时间 (毫秒)
API_TIMEOUT_MS: 30000,
// AI 总结时发送的最大内容长度
AI_CONTENT_MAX_LENGTH: 4000,
// 脚本初始化节流时间 (毫秒)
INIT_THROTTLE_MS: 300,
// 复制成功提示显示时间 (毫秒)
COPY_SUCCESS_DURATION_MS: 2000,
// 复制失败提示显示时间 (毫秒)
COPY_FAILURE_DURATION_MS: 3000,
// 设置保存后关闭延迟 (毫秒)
SETTINGS_CLOSE_DELAY_MS: 300,
// Dialog 关闭动画时间 (毫秒)
DIALOG_CLOSE_ANIMATION_MS: 200,
// 历史复制内容:存储空间不足时的保底条数
COPY_HISTORY_FALLBACK_LIMIT: 20
};
// #endregion
// #region 配置管理
// ==========================================================
/**
* @description 从油猴存储中获取指定键的配置值。
* @param {string} key - 配置项的键名。
* @returns {*} 对应配置项的值,如果不存在则返回默认值。
*/
function getConfig(key) {
return GM_getValue(key, DEFAULT_CONFIG[key]);
}
/**
* @description 将配置值保存到油猴存储中。
* @param {string} key - 配置项的键名。
* @param {*} value - 要保存的配置值。
*/
function setConfig(key, value) {
GM_setValue(key, value);
}
/**
* @description 创建一个动态配置代理对象。
* 当访问 CONFIG.someKey 时,会自动调用 getConfig('someKey')。
* 当设置 CONFIG.someKey = value 时,会自动调用 setConfig('someKey', value)。
*/
const CONFIG = new Proxy({}, {
get(target, prop) {
return getConfig(prop);
},
set(target, prop, value) {
setConfig(prop, value);
return true;
}
});
// #endregion
// #region 样式注入
// ==========================================================
/**
* @description 脚本所需的全部 CSS 样式字符串。
*/
const copyBtnStyle = /*css*/`
.copy-button { /* 统一命名为 .copy-button */
--button-bg: #e5e6eb;
--button-hover-bg: #d7dbe2;
--button-text-color: #4e5969;
--button-hover-text-color: #164de5;
--button-border-radius: 6px;
--button-diameter: 24px;
--button-outline-width: 2px;
--button-outline-color: #9f9f9f;
--tooltip-bg: #1d2129;
--tooltip-border-radius: 4px;
--tooltip-font-family: JetBrains Mono, Consolas, Menlo, Roboto Mono, monospace;
--tooltip-font-size: 12px;
--tooltip-text-color: #fff;
--tooltip-padding-x: 7px;
--tooltip-padding-y: 7px;
--tooltip-offset: 8px;
}
html[style*="color-scheme: dark"] .copy-button,
html.dark .copy-button {
--button-bg: #353434;
--button-hover-bg: #464646;
--button-text-color: #ccc;
--button-outline-color: #999;
--button-hover-text-color: #8bb9fe;
--tooltip-bg: #f4f3f3;
--tooltip-text-color: #111;
}
.copy-button {
box-sizing: border-box;
width: var(--button-diameter);
height: var(--button-diameter);
border-radius: var(--button-border-radius);
background-color: var(--button-bg);
color: var(--button-text-color);
border: none;
cursor: pointer;
position: relative;
outline: var(--button-outline-width) solid transparent;
transition: all 0.2s ease;
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-left: 8px;
}
/* 调整标题的父元素 (h1[data-topic-id]) 为 flex 布局,确保按钮能紧随标题且对齐 */
h1[data-topic-id] {
display: flex !important; /* 强制 flexbox */
align-items: center !important; /* 垂直居中对齐 */
gap: 8px; /* 增加标题和按钮之间的间距 */
}
h1[data-topic-id] .fancy-title {
margin-right: 0 !important; /* 覆盖可能存在的右外边距 */
}
.tooltip {
position: absolute;
opacity: 0;
left: calc(100% + var(--tooltip-offset));
top: 50%;
transform: translateY(-50%);
white-space: nowrap;
font: var(--tooltip-font-size) var(--tooltip-font-family);
color: var(--tooltip-text-color);
background: var(--tooltip-bg);
padding: var(--tooltip-padding-y) var(--tooltip-padding-x);
border-radius: var(--tooltip-border-radius);
pointer-events: none;
transition: all var(--tooltip-transition-duration, 0.3s) cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 1000;
}
.tooltip::before {
content: attr(data-text-initial);
}
.tooltip::after {
content: "";
width: var(--tooltip-padding-y);
height: var(--tooltip-padding-y);
background: inherit;
position: absolute;
top: 50%;
left: calc(var(--tooltip-padding-y) / 2 * -1);
transform: translateY(-50%) rotate(45deg);
z-index: -999;
pointer-events: none;
}
.copy-button svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.checkmark,
.failedmark {
display: none;
}
.copy-button:hover .tooltip,
.copy-button:focus:not(:focus-visible) .tooltip {
opacity: 1;
visibility: visible;
}
.copy-button:focus:not(:focus-visible) .tooltip::before {
content: attr(data-text-end);
}
.copy-button.copy-failed:focus:not(:focus-visible) .tooltip::before {
content: attr(data-text-failed);
}
.copy-button:focus:not(:focus-visible) .clipboard {
display: none;
}
.copy-button:focus:not(:focus-visible) .checkmark {
display: block;
}
.copy-button.copy-failed:focus:not(:focus-visible) .checkmark {
display: none;
}
.copy-button.copy-failed:focus:not(:focus-visible) .failedmark {
display: block;
}
.copy-button:hover,
.copy-button:focus {
background-color: var(--button-hover-bg);
}
.copy-button:active {
outline: var(--button-outline-width) solid var(--button-outline-color);
}
.copy-button:hover svg {
color: var(--button-hover-text-color);
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.6;
}
}
/* 当按钮处于 loading 状态时,应用脉冲动画 */
.copy-button.loading {
animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.copy-button.loading .checkmark,
.copy-button.loading .failedmark {
display: none; /* Loading 时隐藏对勾和叉号 */
}
/* 设置界面样式 - shadcn 风格(简约) */
.linuxdo-settings-dialog {
/* 优先使用 Discourse 主题变量,自动适配深浅色;无变量时回退到浅色 */
--ld-bg: var(--secondary, #ffffff);
--ld-fg: var(--primary, #0f172a);
--ld-muted: var(--primary-very-low, #f1f5f9);
--ld-muted-fg: var(--primary-medium, #64748b);
--ld-card: var(--secondary, #ffffff);
--ld-border: var(--content-border-color, rgba(15, 23, 42, 0.12));
--ld-ring: var(--tertiary-low, rgba(59, 130, 246, 0.45));
--ld-primary: var(--primary, #0f172a);
--ld-primary-fg: var(--secondary, #ffffff);
border: none;
padding: 0;
width: min(720px, calc(100vw - 24px));
max-height: min(85vh, 760px);
background: transparent;
overflow: visible;
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
}
.linuxdo-settings-dialog,
.linuxdo-settings-dialog * {
box-sizing: border-box;
}
html[style*="color-scheme: dark"] .linuxdo-settings-dialog,
html.dark .linuxdo-settings-dialog {
/* 深色模式兜底:仅当站点未提供主题变量时生效 */
--ld-bg: var(--secondary, #0b1220);
--ld-fg: var(--primary, #e2e8f0);
--ld-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12));
--ld-muted-fg: var(--primary-medium, #94a3b8);
--ld-card: var(--secondary, #0f172a);
--ld-border: var(--content-border-color, rgba(148, 163, 184, 0.18));
--ld-ring: var(--tertiary-low, rgba(59, 130, 246, 0.55));
--ld-primary: var(--primary, #e2e8f0);
--ld-primary-fg: var(--secondary, #0b1220);
}
.linuxdo-settings-dialog::backdrop {
background: rgba(2, 6, 23, 0.65);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.linuxdo-settings-content {
background: var(--ld-bg);
color: var(--ld-fg);
border: 1px solid var(--ld-border);
border-radius: 12px;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
display: flex;
flex-direction: column;
max-height: inherit;
overflow: hidden;
}
.linuxdo-settings-dialog[closing] .linuxdo-settings-content {
animation: ldDialogOut 0.16s ease-in forwards;
}
@keyframes ldDialogOut {
to { opacity: 0; transform: translateY(6px) scale(0.985); }
}
.linuxdo-settings-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
padding: 16px 18px;
border-bottom: 1px solid var(--ld-border);
background: var(--ld-bg);
flex-shrink: 0;
}
.linuxdo-settings-title {
font-size: 16px;
font-weight: 600;
line-height: 1.25;
margin: 0;
letter-spacing: -0.01em;
}
.linuxdo-settings-subtitle {
margin: 6px 0 0;
font-size: 12px;
color: var(--ld-muted-fg);
line-height: 1.3;
}
.linuxdo-settings-close {
appearance: none;
border: 1px solid var(--ld-border);
background: transparent;
color: var(--ld-muted-fg);
border-radius: 10px;
width: 34px;
height: 34px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
flex-shrink: 0;
line-height: 1;
}
.linuxdo-settings-close:hover {
background: var(--ld-muted);
color: var(--ld-fg);
}
.linuxdo-settings-close:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ld-ring);
}
.linuxdo-settings-form {
padding: 18px;
overflow-y: auto;
flex: 1;
}
.linuxdo-settings-section + .linuxdo-settings-section {
margin-top: 18px;
}
.linuxdo-settings-section-header {
margin-bottom: 10px;
}
.linuxdo-settings-section-title {
font-size: 12px;
font-weight: 600;
color: var(--ld-muted-fg);
text-transform: uppercase;
letter-spacing: 0.06em;
margin: 0 0 4px;
}
.linuxdo-settings-section-desc {
margin: 0;
font-size: 12px;
color: var(--ld-muted-fg);
}
.linuxdo-settings-card {
border: 1px solid var(--ld-border);
border-radius: 12px;
background: var(--ld-card);
padding: 14px;
display: flex;
flex-direction: column;
gap: 14px;
}
.linuxdo-settings-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
}
.linuxdo-settings-item-text {
min-width: 0;
flex: 1;
}
.linuxdo-settings-item-label {
display: block;
font-size: 14px;
font-weight: 500;
color: var(--ld-fg);
margin: 0;
}
.linuxdo-settings-description {
font-size: 12px;
color: var(--ld-muted-fg);
margin-top: 6px;
line-height: 1.4;
}
.linuxdo-settings-separator {
height: 1px;
width: 100%;
background: var(--ld-border);
}
.linuxdo-settings-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.linuxdo-settings-field {
display: flex;
flex-direction: column;
gap: 6px;
}
.linuxdo-settings-label {
font-size: 11px;
font-weight: 500;
color: var(--ld-fg);
}
.linuxdo-settings-input,
.linuxdo-settings-textarea {
width: 100%;
border: 1px solid var(--ld-border);
background: var(--ld-bg);
color: var(--ld-fg);
border-radius: 9px;
padding: 7px 9px;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
outline: none;
transition: box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.linuxdo-settings-control {
display: inline-flex;
align-items: center;
gap: 6px;
flex-shrink: 0;
}
.linuxdo-settings-input.small {
width: 68px;
text-align: center;
padding: 6px 8px;
}
.linuxdo-settings-unit {
font-size: 11px;
color: var(--ld-muted-fg);
line-height: 1;
}
.linuxdo-settings-input::placeholder,
.linuxdo-settings-textarea::placeholder {
color: var(--ld-muted-fg);
}
.linuxdo-settings-input:focus-visible,
.linuxdo-settings-textarea:focus-visible {
box-shadow: 0 0 0 3px var(--ld-ring);
border-color: rgba(59, 130, 246, 0.65);
}
.linuxdo-settings-textarea {
resize: vertical;
min-height: 90px;
}
/* Switch */
.linuxdo-settings-switch {
position: relative;
width: 44px;
height: 24px;
flex-shrink: 0;
}
.linuxdo-settings-switch input {
opacity: 0;
width: 0;
height: 0;
}
.linuxdo-settings-switch-slider {
position: absolute;
inset: 0;
border-radius: 999px;
border: 1px solid var(--ld-border);
background: var(--ld-muted);
cursor: pointer;
transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.linuxdo-settings-switch-slider:before {
position: absolute;
content: "";
top: 2px;
left: 2px;
width: 20px;
height: 20px;
border-radius: 999px;
background: var(--ld-bg);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
transition: transform 0.15s ease, background 0.15s ease;
}
.linuxdo-settings-switch input:checked + .linuxdo-settings-switch-slider {
background: var(--ld-primary);
border-color: var(--ld-primary);
}
.linuxdo-settings-switch input:checked + .linuxdo-settings-switch-slider:before {
transform: translateX(20px);
background: var(--ld-primary-fg);
}
.linuxdo-settings-switch input:focus-visible + .linuxdo-settings-switch-slider {
box-shadow: 0 0 0 3px var(--ld-ring);
}
.linuxdo-settings-footer {
display: flex;
gap: 10px;
padding: 14px 18px;
padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
border-top: 1px solid var(--ld-border);
background: var(--ld-bg);
flex-shrink: 0;
}
.linuxdo-settings-button {
flex: 1;
padding: 10px 14px;
border-radius: 10px;
border: 1px solid var(--ld-border);
background: transparent;
color: var(--ld-fg);
cursor: pointer;
font-size: 13px;
font-weight: 500;
font-family: inherit;
transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.linuxdo-settings-button:hover {
background: var(--ld-muted);
}
.linuxdo-settings-button:active {
transform: translateY(1px);
}
.linuxdo-settings-button:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ld-ring);
}
.linuxdo-settings-button.primary {
background: var(--ld-primary);
border-color: var(--ld-primary);
color: var(--ld-primary-fg);
}
.linuxdo-settings-button.primary:hover {
filter: brightness(0.98);
}
@media (max-width: 520px) {
.linuxdo-settings-dialog {
width: calc(100vw - 16px);
max-height: 92vh;
}
.linuxdo-settings-form {
padding: 14px;
}
.linuxdo-settings-header,
.linuxdo-settings-footer {
padding-left: 14px;
padding-right: 14px;
}
.linuxdo-settings-grid {
grid-template-columns: 1fr;
}
}
/* 历史复制内容(搜索框右侧) */
.linuxdo-copy-history-trigger {
--ld-h-bg: var(--secondary, #ffffff);
--ld-h-fg: var(--primary, #0f172a);
--ld-h-muted: var(--primary-very-low, #f1f5f9);
--ld-h-muted-fg: var(--primary-medium, #64748b);
--ld-h-border: var(--primary-low, rgba(15, 23, 42, 0.12));
--ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.45));
appearance: none;
border: 1px solid var(--ld-h-border);
background: transparent;
color: var(--ld-h-muted-fg);
width: 32px;
height: 32px;
border-radius: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
margin-left: 2px;
margin-right: 2px;
transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
html[style*="color-scheme: dark"] .linuxdo-copy-history-trigger,
html.dark .linuxdo-copy-history-trigger {
--ld-h-bg: var(--secondary, #111827);
--ld-h-fg: var(--primary, #e5e7eb);
--ld-h-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12));
--ld-h-muted-fg: var(--primary-medium, #9ca3af);
--ld-h-border: var(--primary-low, rgba(148, 163, 184, 0.18));
--ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.55));
}
.linuxdo-copy-history-trigger:hover {
background: var(--ld-h-muted);
color: var(--ld-h-fg);
}
.linuxdo-copy-history-trigger:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-trigger svg {
width: 16px;
height: 16px;
display: block;
}
.linuxdo-copy-history-popover {
--ld-h-bg: var(--secondary, #ffffff);
--ld-h-fg: var(--primary, #0f172a);
--ld-h-muted: var(--primary-very-low, #f1f5f9);
--ld-h-muted-fg: var(--primary-medium, #64748b);
--ld-h-border: var(--primary-low, rgba(15, 23, 42, 0.12));
--ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.18));
position: fixed;
z-index: 100000;
width: min(520px, calc(100vw - 24px));
max-height: min(70vh, 520px);
overflow: auto;
background: var(--ld-h-bg);
color: var(--ld-h-fg);
border: 1px solid var(--ld-h-border);
border-radius: 12px;
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
padding: 10px;
display: none;
}
html[style*="color-scheme: dark"] .linuxdo-copy-history-popover,
html.dark .linuxdo-copy-history-popover {
--ld-h-bg: var(--secondary, #111827);
--ld-h-fg: var(--primary, #e5e7eb);
--ld-h-muted: var(--primary-very-low, rgba(148, 163, 184, 0.12));
--ld-h-muted-fg: var(--primary-medium, #9ca3af);
--ld-h-border: var(--primary-low, rgba(148, 163, 184, 0.18));
--ld-h-ring: var(--tertiary-low, rgba(59, 130, 246, 0.24));
box-shadow: 0 24px 90px rgba(0, 0, 0, 0.52);
}
.linuxdo-copy-history-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
padding: 2px 2px 10px;
border-bottom: 1px solid var(--ld-h-border);
margin-bottom: 8px;
}
.linuxdo-copy-history-header-left {
display: inline-flex;
align-items: center;
gap: 8px;
min-width: 0;
}
.linuxdo-copy-history-title {
font-size: 12px;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--ld-h-muted-fg);
}
.linuxdo-copy-history-select-all {
display: inline-flex;
align-items: center;
gap: 6px;
height: 24px;
padding: 0 10px;
border-radius: 10px;
border: 1px solid var(--ld-h-border);
background: transparent;
font-size: 12px;
font-weight: 500;
line-height: 1;
color: var(--ld-h-muted-fg);
user-select: none;
cursor: pointer;
white-space: nowrap;
transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.linuxdo-copy-history-select-all:hover {
background: var(--ld-h-muted);
color: var(--ld-h-fg);
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-select-all:active {
transform: translateY(1px);
}
.linuxdo-copy-history-select-all input[type="checkbox"] {
width: 14px;
height: 14px;
margin: 0;
display: block;
cursor: pointer;
accent-color: var(--tertiary, #3b82f6);
}
.linuxdo-copy-history-settings-btn,
.linuxdo-copy-history-delete-btn {
appearance: none;
border: 1px solid var(--ld-h-border);
background: transparent;
color: var(--ld-h-muted-fg);
height: 24px;
padding: 0 10px;
border-radius: 10px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 12px;
font-weight: 500;
line-height: 1;
transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.linuxdo-copy-history-settings-btn:hover,
.linuxdo-copy-history-delete-btn:hover {
background: var(--ld-h-muted);
color: var(--ld-h-fg);
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-settings-btn:active,
.linuxdo-copy-history-delete-btn:active {
transform: translateY(1px);
}
.linuxdo-copy-history-settings-btn:focus-visible,
.linuxdo-copy-history-delete-btn:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-delete-btn {
color: var(--danger, #b91c1c);
}
.linuxdo-copy-history-delete-btn:hover {
background: var(--danger-low, rgba(239, 68, 68, 0.12));
color: var(--danger, #991b1b);
box-shadow: 0 0 0 3px var(--danger-low, rgba(239, 68, 68, 0.22));
}
.linuxdo-copy-history-delete-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.linuxdo-copy-history-delete-btn:disabled:hover {
background: transparent;
color: var(--ld-h-muted-fg);
box-shadow: none;
}
.linuxdo-copy-history-hint {
font-size: 12px;
color: var(--ld-h-muted-fg);
white-space: nowrap;
}
.linuxdo-copy-history-list {
display: flex;
flex-direction: column;
gap: 8px;
}
.linuxdo-copy-history-item {
border: 1px solid var(--ld-h-border);
border-radius: 12px;
padding: 10px;
background: transparent;
transition: background 0.15s ease, box-shadow 0.15s ease;
}
.linuxdo-copy-history-item.is-selected {
background: var(--ld-h-muted);
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-item:hover {
background: var(--ld-h-muted);
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-item-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 10px;
}
.linuxdo-copy-history-item-checkbox-wrap {
display: inline-flex;
align-items: flex-start;
padding-top: 2px;
flex-shrink: 0;
}
.linuxdo-copy-history-item-checkbox {
width: 14px;
height: 14px;
margin: 0;
display: block;
cursor: pointer;
accent-color: var(--tertiary, #3b82f6);
}
.linuxdo-copy-history-item-text {
min-width: 0;
flex: 1;
}
.linuxdo-copy-history-item-title {
font-size: 13px;
font-weight: 600;
line-height: 1.35;
margin: 0;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.linuxdo-copy-history-item-snippet {
margin-top: 4px;
font-size: 12px;
color: var(--ld-h-muted-fg);
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.linuxdo-copy-history-actions {
display: flex;
gap: 6px;
flex-shrink: 0;
}
.linuxdo-copy-history-btn {
appearance: none;
border: 1px solid var(--ld-h-border);
background: transparent;
color: var(--ld-h-fg);
border-radius: 10px;
padding: 6px 10px;
font-size: 12px;
font-weight: 500;
cursor: pointer;
transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
white-space: nowrap;
}
.linuxdo-copy-history-btn:hover {
background: var(--ld-h-muted);
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-btn:active {
transform: translateY(1px);
}
.linuxdo-copy-history-btn:focus-visible {
outline: none;
box-shadow: 0 0 0 3px var(--ld-h-ring);
}
.linuxdo-copy-history-empty {
padding: 18px 8px;
text-align: center;
font-size: 12px;
color: var(--ld-h-muted-fg);
}
`;
/**
* @description 将 CSS 样式注入到页面中。
* 优先使用 GM_addStyle API,如果不可用,则创建一个 <style> 标签并插入到 <head> 中。
* @param {string} cssText - 要注入的 CSS 样式字符串。
*/