-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfkeys.js
618 lines (603 loc) · 17.9 KB
/
sfkeys.js
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
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Normal.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
stealFocusOnLoad=true;
enableAutoFocus=false;
omnibarSuggestion=true;
// -----------------------------------------------------------------------------------------------------------------------
// Change hints styles
// -----------------------------------------------------------------------------------------------------------------------
Hints.characters = "asdfgqwertvbn";
//Hints.style('border: solid 0px #ff79c6; color:#44475a; background: #f1fa8c; background-color: #f1fa8c; font-size: 9pt; font-family: "Microsoft YaHei", "Inconsolata", "Tahoma", "SimSun", "FontAwesome", "Segoe UI", "Segoe UI Symbol", "Symbola", "Meiryo", "Malgun Gothic", "NSimSun", "FZSongS", "方正宋体S-超大字符集", "Arial Unicode MS"');
//Hints.style("border: solid 0px #ff79c6; padding: 1px; background: #7FAB97; font-size: 9pt; font-family: 'Microsoft YaHei', 'Inconsolata', 'Tahoma', 'SimSun', 'FontAwesome', 'Segoe UI', 'Segoe UI Symbol', 'Symbola', 'Meiryo', 'Malgun Gothic', 'NSimSun', 'FZSongS', '方正宋体S-超大字符集', 'Arial Unicode MS'", "text");
// -----------------------------------------------------------------------------------------------------------------------
// Change search marks and cursor
// -----------------------------------------------------------------------------------------------------------------------
//Visual.style('marks', 'background-color: #f1fa8c;');
//Visual.style('cursor', 'background-color: #6272a4; color: #f8f8f2');
// ---- Hints ----
// Hints have to be defined separately
// Uncomment to enable
// Tomorrow-Night
/* -- DELETE LINE TO ENABLE THEME
Hints.style('border: solid 2px #373B41; color:#52C196; background: initial; background-color: #1D1F21;');
Hints.style("border: solid 2px #373B41 !important; padding: 1px !important; color: #C5C8C6 !important; background: #1D1F21 !important;", "text");
Visual.style('marks', 'background-color: #52C19699;');
Visual.style('cursor', 'background-color: #81A2BE;');
-- DELETE LINE TO ENABLE THEME */
// Nord
/* -- DELETE LINE TO ENABLE THEME
Hints.style('border: solid 2px #4C566A; color:#A3BE8C; background: initial; background-color: #3B4252;');
Hints.style("border: solid 2px #4C566A !important; padding: 1px !important; color: #E5E9F0 !important; background: #3B4252 !important;", "text");
Visual.style('marks', 'background-color: #A3BE8C99;');
Visual.style('cursor', 'background-color: #88C0D0;');
-- DELETE LINE TO ENABLE THEME */
// Doom One
Hints.style('border: solid 2px #282C34; color:#98be65; background: initial; background-color: #2E3440;');
Hints.style("border: solid 2px #282C34 !important; padding: 1px !important; color: #51AFEF !important; background: #2E3440 !important;", "text");
Visual.style('marks', 'background-color: #98be6599;');
Visual.style('cursor', 'background-color: #51AFEF;');
// Monokai
/* -- DELETE LINE TO ENABLE THEME
Hints.style('border: solid 2px #2D2E2E; color:#F92660; background: initial; background-color: #272822;');
Hints.style("border: solid 2px #2D2E2E !important; padding: 1px !important; color: #A6E22E !important; background: #272822 !important;", "text");
Visual.style('marks', 'background-color: #A6E22E99;');
Visual.style('cursor', 'background-color: #F92660;');
-- DELETE LINE TO ENABLE THEME */
//mapkey('H', '#4Go back in history', 'history.go(-1)');
//mapkey('L', '#4Go forward in history', 'history.go(1)');
// an example to remove mapkey `Ctrl-i`
// unmap('<Ctrl-i>');
unmap('gr');
unmap('spa');
unmap('spb');
unmap('spd');
unmap('sps');
unmap('spc');
unmap('F');
unmap('gc');
unmap('as');
unmap('aa');
unmap('ar');
unmap('od');
unmap('oe');
unmap('og');
unmap('or');
unmap('sd');
unmap('sg');
unmap('om');
unmap('ss');
unmap('sm');
unmap('.');
//unmap('f');
// search engine
addSearchAliasX('zh', 'zhihu', 'https://www.zhihu.com/search?type=question&q=', 's');
addSearchAliasX('e', 'ecosia', 'https://www.ecosia.org/search?q=', 's');
addSearchAliasX('f', 'fsou', 'https://fsou.cc/search?q=', 's');
//addSearchAliasX('p', 'panc', 'https://www.panc.cc/m/s/?s=', 's');
addSearchAliasX('dd', 'duckduckgo', 'https://duckduckgo.com/?q=', 's');
addSearchAliasX('db', 'douban', 'https://www.douban.com/search?source=suggest&q=', 's');
addSearchAliasX('dm', 'douban movie', 'https://www.douban.com/search?source=suggest&cat=1002&q=', 's');
//addSearchAliasX('t', 'translate', 'https://translate.google.cn/?source=osdd#auto/zh-CN/', 's');
addSearchAliasX('sm', 'smzdm', 'https://search.smzdm.com/?c=post&s=', 's');
addSearchAliasX('sf', 'SegmentFault', 'https://segmentfault.com/search?type=all&q=', 's');
addSearchAliasX('sb', 'bing', 'https://www.bing.com/search?q=', 's');
//addSearchAliasX('sx', 'searx', 'https://searx.info/?q=', 's');
//addSearchAliasX('sx', 'searx', 'https://searx.info/?q=', 's');
//addSearchAliasX('sx', 'searx', 'https://searx.fmac.xyz/?q=', 's');
addSearchAliasX('so', 'stackoverflow', 'https://stackoverflow.com/search?q=', 's');
addSearchAliasX('md', 'mdn', 'https://developer.mozilla.org/zh-CN/search?q=', 's');
addSearchAliasX('jd', 'jd', 'https://search.jd.com/Search?enc=utf-8&keyword=', 's');
addSearchAliasX('jj', 'juejin', 'https://juejin.cn/search?query=', 's');
addSearchAliasX('js', 'jianshu', 'https://www.jianshu.com/search?q=', 's');
addSearchAliasX('gh', 'github', 'https://github.com/search?q=', 's');
addSearchAliasX('rr', 'rarbg', 'https://rarbgto.org/torrents.php?search=', 's');
//addSearchAliasX('ms', 'mengso', 'https://mengso.com/search?q=', 's');
addSearchAliasX('gg', 'google', 'https://www.google.com/search?pws=0&gl=us&gws_rd=cr&q=', 's');
//mapkey('osx', 'call searx', function() {
// Front.openOmnibar({
// type: "SearchEngine",
// extra: 'sx'
// });
//});
mapkey('osm', 'call smzdm search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'sm'
});
});
mapkey('osb', 'call bing search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'sb'
});
});
mapkey('oso', 'call stackoverflow search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'so'
});
});
mapkey('osf', 'call segmentfault search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'sf'
});
});
mapkey('omd', 'call mdn search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'md'
});
});
//mapkey('oms', 'call mengso search', function() {
// Front.openOmnibar({
// type: "SearchEngine",
// extra: 'ms'
// });
//});
mapkey('ojd', 'call jd search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'jd'
});
});
mapkey('ojj', 'call juejin search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'jj'
});
});
mapkey('ojs', 'call jianshu search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'js'
});
});
mapkey('ogh', 'call github search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'gh'
});
});
mapkey('ogg', 'call google search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'gg'
});
});
mapkey('oe', 'call ecosia search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'e'
});
});
mapkey('of', 'call fsou search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'f'
});
});
mapkey('odb', 'call douban search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'db'
});
});
mapkey('odm', 'call douban movie search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'dm'
});
});
mapkey('odd', 'call dockduckgo search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'dd'
});
});
/**mapkey('op', 'call pancc search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'p'
});
});**/
mapkey('ozh', 'call zhihu search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'zh'
});
});
mapkey('orr', 'call rarbg search', function() {
Front.openOmnibar({
type: "SearchEngine",
extra: 'rr'
});
});
//map('or', ':openSession r');
mapkey("-j", "google translate", () => {
const selection = window.getSelection().toString();
if (selection === "") {
tabOpenLink(
`http://translate.google.com/translate?u=${window.location.href}`
);
} else {
tabOpenLink(
`https://translate.google.com/?sl=auto&tl=ja&text=${encodeURIComponent(
selection
)}`
);
}
});
mapkey("-c", "google translate", () => {
const selection = window.getSelection().toString();
if (selection === "") {
tabOpenLink(
`http://translate.google.com/translate?u=${window.location.href}`
);
} else {
tabOpenLink(
`https://translate.google.com/?sl=auto&tl=zh-CN&text=${encodeURIComponent(
selection
)}`
);
}
});
mapkey("-e", "google translate", () => {
const selection = window.getSelection().toString();
if (selection === "") {
tabOpenLink(
`http://translate.google.com/translate?u=${window.location.href}`
);
} else {
tabOpenLink(
`https://translate.google.com/?sl=auto&tl=en&text=${encodeURIComponent(
selection
)}`
);
}
});
Front.registerInlineQuery({
url: function(q) {
return `http://dict.youdao.com/w/eng/${q}/#keyfrom=dict2.index`;
},
parseResult: function(res) {
var parser = new DOMParser();
var doc = parser.parseFromString(res.text, "text/html");
var collinsResult = doc.querySelector("#collinsResult");
var authTransToggle = doc.querySelector("#authTransToggle");
var examplesToggle = doc.querySelector("#examplesToggle");
if (collinsResult) {
collinsResult.querySelectorAll("div>span.collinsOrder").forEach(function(span) {
span.nextElementSibling.prepend(span);
});
collinsResult.querySelectorAll("div.examples").forEach(function(div) {
div.innerHTML = div.innerHTML.replace(/<p/gi, "<span").replace(/<\/p>/gi, "</span>");
});
var exp = collinsResult.innerHTML;
return exp;
} else if (authTransToggle) {
authTransToggle.querySelector("div.via.ar").remove();
return authTransToggle.innerHTML;
} else if (examplesToggle) {
return examplesToggle.innerHTML;
}
}
});
// an example to replace `u` with `?`, click `Default mappings` to see how `u` works.
//map('?', 'u');
//map('J','E');
//map('K','R');
//map('F','af');
//map('f','gf');
// Set H and L for back/forward
// mapkey('S', '#8Open opened URL in current tab', 'Normal.openOmnibar({type: "URLs", extra: "getTabURLs"})');
// mapkey('H', '#4Go back in history', 'history.go(-1)');
// mapkey('L', '#4Go forward in history', 'history.go(1)');
// Tabs
//mapkey('gT', '#3Go one tab left', 'RUNTIME("previousTab")');
//mapkey('gt', '#3Go one tab right', 'RUNTIME("nextTab")');
mapkey('gc', '#12Open Chrome Configure', function() {
tabOpenLink("chrome://settings/");
});
settings.blacklistPattern = /.*mail.google.com.*|.*inbox.google.com.*|trello.com|feishu.cn|inoreader.com|route.asus.com|localhost/i;
settings.nextLinkRegex = /((>>|下一页|next|older posts|older entries|forward|Next »|>|>>|❯|›|»|more|下一张|下页|(阅读)?下一章|下一章|次へ)+)/i;
settings.prevLinkRegex = /((<<|上一页|prev(ious)?|newer posts|newer entries|« Previous|back|<|❮|<<«|less|‹|上一张|(阅读)?上一章|上一章|前へ)+)/i;
// Prevent automatic next/previous page loads
settings.smartPageBoundary = false;
settings.stealFocusOnLoad = false;
// set theme
/* -- DELETE LINE TO ENABLE THEME
settings.theme = `
.sk_theme {
background: #100a14dd;
color: #4f97d7;
}
.sk_theme tbody {
color: #292d;
}
.sk_theme input {
color: #d9dce0;
}
.sk_theme .url {
color: #2d9574;
}
.sk_theme .annotation {
color: #a31db1;
}
.sk_theme .omnibar_highlight {
color: #333;
background: #ffff00aa;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: #5d4d7a55;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: #5d4d7aaa;
}
.sk_theme #sk_omnibarSearchResult .omnibar_folder {
color: #a31db1;
}
`;
-- DELETE LINE TO ENABLE THEME */
settings.theme = `
/* Edit these variables for easy theme making */
:root {
/* Font */
--font: 'Microsoft YaHei', 'FontAwesome', 'Meiryo', 'Source Code Pro', Ubuntu, sans;
--font-size: 18;
--font-weight: bold;
/* -------------- */
/* --- THEMES --- */
/* -------------- */
/* -------------------- */
/* -- Tomorrow Night -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #C5C8C6;
--bg: #282A2E;
--bg-dark: #1D1F21;
--border: #373b41;
--main-fg: #81A2BE;
--accent-fg: #52C196;
--info-fg: #AC7BBA;
--select: #585858;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --cyan: #4CB3BC; */
/* --orange: #DE935F; */
/* --red: #CC6666; */
/* --yellow: #CBCA77; */
/* -------------------- */
/* -- NORD -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #E5E9F0;
--bg: #3B4252;
--bg-dark: #2E3440;
--border: #4C566A;
--main-fg: #88C0D0;
--accent-fg: #A3BE8C;
--info-fg: #5E81AC;
--select: #4C566A;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --orange: #D08770; */
/* --red: #BF616A; */
/* --yellow: #EBCB8B; */
/* -------------------- */
/* -- DOOM ONE -- */
/* -------------------- */
--fg: #51AFEF;
--bg: #2E3440;
--bg-dark: #21242B;
--border: #2257A0;
--main-fg: #51AFEF;
--accent-fg: #98be65;
--info-fg: #C678DD;
--select: #4C566A;
/* Unused Alternate Colors */
/* --border-alt: #282C34; */
/* --cyan: #46D9FF; */
/* --orange: #DA8548; */
/* --red: #FF6C6B; */
/* --yellow: #ECBE7B; */
/* -------------------- */
/* -- MONOKAI -- */
/* -------------------- */
/* -- DELETE LINE TO ENABLE THEME
--fg: #F8F8F2;
--bg: #272822;
--bg-dark: #1D1E19;
--border: #2D2E2E;
--main-fg: #F92660;
--accent-fg: #E6DB74;
--info-fg: #A6E22E;
--select: #556172;
-- DELETE LINE TO ENABLE THEME */
/* Unused Alternate Colors */
/* --red: #E74C3C; */
/* --orange: #FD971F; */
/* --blue: #268BD2; */
/* --violet: #9C91E4; */
/* --cyan: #66D9EF; */
}
/* ---------- Generic ---------- */
.sk_theme {
background: var(--bg);
color: var(--fg);
background-color: var(--bg);
border-color: var(--border);
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
}
input {
font-family: var(--font);
font-weight: var(--font-weight);
}
.sk_theme tbody {
color: var(--fg);
}
.sk_theme input {
color: var(--fg);
}
/* Hints */
#sk_hints .begin {
color: var(--accent-fg) !important;
}
#sk_tabs .sk_tab {
background: var(--bg-dark);
border: 1px solid var(--border);
}
#sk_tabs .sk_tab_title {
color: var(--fg);
}
#sk_tabs .sk_tab_url {
color: var(--main-fg);
}
#sk_tabs .sk_tab_hint {
background: var(--bg);
border: 1px solid var(--border);
color: var(--accent-fg);
}
.sk_theme #sk_frame {
background: var(--bg);
opacity: 0.2;
color: var(--accent-fg);
}
/* ---------- Omnibar ---------- */
/* Uncomment this and use settings.omnibarPosition = 'bottom' for Pentadactyl/Tridactyl style bottom bar */
/* .sk_theme#sk_omnibar {
width: 100%;
left: 0;
} */
.sk_theme .title {
color: var(--accent-fg);
}
.sk_theme .url {
color: var(--main-fg);
}
.sk_theme .annotation {
color: var(--accent-fg);
}
.sk_theme .omnibar_highlight {
color: var(--accent-fg);
}
.sk_theme .omnibar_timestamp {
color: var(--info-fg);
}
.sk_theme .omnibar_visitcount {
color: var(--accent-fg);
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: var(--bg-dark);
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: var(--border);
}
.sk_theme #sk_omnibarSearchArea {
border-top-color: var(--border);
border-bottom-color: transparent;
}
.sk_theme #sk_omnibarSearchArea input,
.sk_theme #sk_omnibarSearchArea span {
font-size: var(--font-size);
}
.sk_theme .separator {
color: var(--accent-fg);
}
/* ---------- Popup Notification Banner ---------- */
#sk_banner {
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
background: var(--bg);
border-color: var(--border);
color: var(--fg);
opacity: 0.9;
}
/* ---------- Popup Keys ---------- */
#sk_keystroke {
background-color: var(--bg);
}
.sk_theme kbd .candidates {
color: var(--info-fg);
}
.sk_theme span.annotation {
color: var(--accent-fg);
}
/* ---------- Popup Translation Bubble ---------- */
#sk_bubble {
background-color: var(--bg) !important;
color: var(--fg) !important;
border-color: var(--border) !important;
}
#sk_bubble * {
color: var(--fg) !important;
}
#sk_bubble div.sk_arrow div:nth-of-type(1) {
border-top-color: var(--border) !important;
border-bottom-color: var(--border) !important;
}
#sk_bubble div.sk_arrow div:nth-of-type(2) {
border-top-color: var(--bg) !important;
border-bottom-color: var(--bg) !important;
}
/* ---------- Search ---------- */
#sk_status,
#sk_find {
font-size: var(--font-size);
border-color: var(--border);
}
.sk_theme kbd {
background: var(--bg-dark);
border-color: var(--border);
box-shadow: none;
color: var(--fg);
}
.sk_theme .feature_name span {
color: var(--main-fg);
}
/* ---------- ACE Editor ---------- */
#sk_editor {
background: var(--bg-dark) !important;
height: 50% !important;
/* Remove this to restore the default editor size */
}
.ace_dialog-bottom {
border-top: 1px solid var(--bg) !important;
}
.ace-chrome .ace_print-margin,
.ace_gutter,
.ace_gutter-cell,
.ace_dialog {
background: var(--bg) !important;
}
.ace-chrome {
color: var(--fg) !important;
}
.ace_gutter,
.ace_dialog {
color: var(--fg) !important;
}
.ace_cursor {
color: var(--fg) !important;
}
.normal-mode .ace_cursor {
background-color: var(--fg) !important;
border: var(--fg) !important;
opacity: 0.7 !important;
}
.ace_marker-layer .ace_selection {
background: var(--select) !important;
}
.ace_editor,
.ace_dialog span,
.ace_dialog input {
font-family: var(--font);
font-size: var(--font-size);
font-weight: var(--font-weight);
}
`;