-
Notifications
You must be signed in to change notification settings - Fork 2
/
surfingkeys-configold.js
533 lines (514 loc) · 13.8 KB
/
surfingkeys-configold.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
// Removing default search aliases
api.removeSearchAlias("b");
api.removeSearchAlias("g");
api.removeSearchAlias("s");
api.removeSearchAlias("w");
api.removeSearchAlias("p");
// [+] Remove omnibar mappings to removed search aliases
api.unmap("oi");
api.unmap("ob");
api.unmap("og");
api.unmap("os");
api.unmap("ow");
api.unmap("op");
api.unmap("oy");
api.unmap("od");
api.map(',nt', 'T');
api.map(',q', 'x');
api.mapkey(',s', 'opne new tab and split', function () {
RUNTIME("newWindow");
});
api.mapkey('b', 'Select a block and hide others', function() {
// Override the create function to modify its behavior
Hints.create("asdfghjkl;", function(element) {
// Assuming the element clicked is within the desired div or is the div itself
let targetDiv = element.closest('div'); // Finds the closest ancestor which is a div
if (targetDiv) {
// Apply styles or classes to dim or hide all other elements
document.querySelectorAll('body > *').forEach(function(el) {
// Check if the current element is not the targetDiv or its ancestor
if (!targetDiv.contains(el) && el !== targetDiv) {
el.style.display = 'none'; // Hide elements outside the target div
}
});
}
// Optionally, dispatch a click on the element if needed
// element.click(); // Uncomment if you actually need to simulate the click
}, {repeatIgnore: true});
});
settings.tabsThreshold = 0;
const API_KEY = "af712d02-1689-4378-8590-cba02e8341a0";
const API_URL = "https://dictionaryapi.com/api/v3";
// api.mapkey("h", "Go to the first Google result", function () {
// // Selector for the first search result title
// var firstResult = document.querySelector(".LC20lb");
// // Ensure the element exists and has a parent node which should be the anchor tag
// if (firstResult && firstResult.parentNode) {
// // Navigate to the href of the parent node
// window.location.href = firstResult.parentNode.href;
// } else {
// // Alert if no result is found
// alert("No search result link found.");
// } });
//
api.mapkey("1h", "Go to the first Google result", function () {
goToLink(0);
});
api.mapkey("2h", "Go to the second Google result", function () {
goToLink(1);
});
api.mapkey("3h", "Go to the third Google result", function () {
goToLink(2);
});
function goToLink(index) {
// Selector for search result container
var searchResultContainers = document.querySelectorAll("#search .g");
// Ensure the selected search result container exists
if (searchResultContainers.length > index) {
// Find the anchor tag within the selected container
var anchor = searchResultContainers[index].querySelector("a");
if (anchor && anchor.href) {
// Navigate to the href of the anchor tag
window.location.href = anchor.href;
} else {
// Alert if no anchor is found or if it does not contain an href
alert(
"No navigable link found for search result at position " + (index + 1),
);
}
} else {
// Alert if the specified search result container is not found
alert("No search result container found at position " + (index + 1));
}
}
api.Front.registerInlineQuery({
url: function (q) {
const url = `${API_URL}/references/learners/json/${q}?key=${API_KEY}`;
return url;
},
parseResult: function (res) {
try {
const [firstResult] = JSON.parse(res.text);
if (firstResult) {
let definitionsList = `<ul><li>No definitions found</li></ul>`;
let pronunciationsList = `<ul><li>No pronunciations found</li></ul>`;
if (firstResult.hasOwnProperty("shortdef")) {
const definitions = [];
for (let definition of firstResult.shortdef) {
definitions.push(`${definition}`);
}
const definitionListItems = definitions.map(function (definition) {
return `<li>${definition}</li>`;
});
definitionsList = `<ul>${definitionListItems.join("")}</ul>`;
//TODO: Separate this function if possible
}
if (firstResult.hasOwnProperty("hwi")) {
const pronunciations = [];
const resultPronunciationsArray = firstResult.hwi.prs;
if (
resultPronunciationsArray &&
resultPronunciationsArray.length !== 0
) {
for (let i = 0; i < resultPronunciationsArray.length; i++) {
if (resultPronunciationsArray[i].l) {
pronunciations.push(
`<li>${resultPronunciationsArray[i].l} -- ${resultPronunciationsArray[i].ipa}</li>`,
);
} else {
pronunciations.push(
`<li>${resultPronunciationsArray[i].ipa}</li>`,
);
}
}
pronunciationsList = `<ul>${pronunciations.join("")}</ul>`;
}
}
return `
<h3>Pronunciations</h3>
${pronunciationsList}
<hr/>
<h3>Definitions</h3>
${definitionsList}
`;
} else {
return `
<h3>This is not the definition you were looking for...</h3>
`;
}
} catch (e) {
console.log(e.message);
return "Something bad happend... Look behind you, a three headed monkey!";
}
},
});
// Map 'yg' to copy the git clone command for GitHub repositories
api.mapkey("yg", "Copy git clone command", function () {
// Check if the current page is a GitHub repository
if (/github\.com/i.test(window.location.href)) {
// Construct the git clone command
var gitCommand = "git clone " + window.location.href + ".git";
// Copy the command to the clipboard
api.Clipboard.write(gitCommand);
// Optionally, you can display a message to the user
api.Front.showBanner(`Copied to clipboard: ${gitCommand}`);
} else {
api.Front.showBanner("Not a GitHub repository page", 3000);
}
});
api.addSearchAlias("G", "Google Search", "https://www.google.com/search?q={0}");
api.addSearchAlias(
"gm",
"Google Month",
"https://www.google.com/search?q={0}&tbs=qdr:m",
);
api.addSearchAlias(
"gM",
"MDN Docs",
"www.google.com/search?btnI=1&q=mdn+{0}",
);
api.addSearchAlias(
"gw",
"Google Week",
"https://www.google.com/search?q={0}&tbs=qdr:w",
);
api.addSearchAlias(
"gy",
"Google Year",
"https://www.google.com/search?q={0}&tbs=qdr:y",
);
api.addSearchAlias(
"gd",
"Google Day",
"https://www.google.com/search?q={0}&tbs=qdr:d",
);
api.addSearchAlias(
"gH",
"Google Hour",
"https://www.google.com/search?q={0}&tbs=qdr:h",
);
api.addSearchAlias(
"gsh",
"Google Search History",
"https://myactivity.google.com/myactivity?authuser=0&q={0}",
);
api.addSearchAlias(
"gi",
"Google Images",
"https://www.google.com/search?q={0}&tbm=isch",
);
api.addSearchAlias(
"os",
"One Search",
"https://historysearch.com/search/list?q={0}",
);
api.addSearchAlias(
"hs",
"History Search",
"https://historysearch.com/search/list?q={0}",
);
api.addSearchAlias(
"dee",
"Envato Elements",
"https://elements.envato.com/all-items/{0}",
);
api.addSearchAlias(
"db",
"Behance",
"https://www.behance.net/search?search={0}",
);
api.addSearchAlias("dd", "Dribble", "https://dribbble.com/search/{0}");
api.addSearchAlias(
"daw",
"Awwards",
"https://www.awwwards.com/inspiration/search?text={0}",
);
api.addSearchAlias(
"dui",
"UI Sources",
"https://www.uisources.com/search?query={0}",
);
api.addSearchAlias("dm", "Muzli", "https://search.muz.li/search/{0}");
api.addSearchAlias("dpu", "Unsplash", "https://unsplash.com/s/photos/{0}");
api.addSearchAlias(
"dps",
"Shutterstock",
"https://www.shutterstock.com/search/{0}",
);
api.addSearchAlias("dpp", "Pexels", "https://www.pexels.com/search/{0}/");
api.addSearchAlias(
"yy",
"YouTube Year",
"https://www.youtube.com/results?search_query={0}&sp=EgIIBQ%253D%253D",
);
api.addSearchAlias(
"ym",
"YouTube Month",
"https://www.youtube.com/results?search_query={0}&sp=EgQIBBAB",
);
api.addSearchAlias(
"yw",
"YouTube Week",
"https://www.youtube.com/results?search_query={0}&sp=EgQIAxAB",
);
api.addSearchAlias(
"yd",
"YouTube Day",
"https://www.youtube.com/results?search_query={0}&sp=EgQIAhAB",
);
api.addSearchAlias(
"yh",
"YouTube Hour",
"https://www.youtube.com/results?search_query={0}&sp=EgQIARAB",
);
api.addSearchAlias(
"yc",
"YouTube Channel",
"https://www.youtube.com/results?search_query={0}&sp=EgIQAg%253D%253D",
);
api.addSearchAlias(
"yp",
"YouTube Playlist",
"https://www.youtube.com/results?search_query={0}&sp=EgIQAw%253D%253D",
);
api.addSearchAlias(
"yM",
"YouTube Movie",
"https://www.youtube.com/results?search_query={0}&sp=EgIQBA%253D%253D",
);
api.addSearchAlias(
"ySh",
"YouTube Show",
"https://www.youtube.com/results?search_query={0}&sp=EgIQBQ%253D%253D",
);
api.addSearchAlias(
"ys",
"YouTube Short",
"https://www.youtube.com/results?search_query={0}&sp=EgIYAQ%253D%253D",
);
api.addSearchAlias(
"ylo",
"YouTube Long",
"https://www.youtube.com/results?search_query={0}&sp=EgIYAg%253D%253D",
);
api.addSearchAlias(
"yli",
"YouTube Live",
"https://www.youtube.com/results?search_query={0}&sp=EgJAAQ%253D%253D",
);
api.addSearchAlias(
"y4k",
"YouTube 4K",
"https://www.youtube.com/results?search_query={0}&sp=EgJwAQ%253D%253D",
);
api.addSearchAlias(
"yHD",
"YouTube HD",
"https://www.youtube.com/results?search_query={0}&sp=EgIgAQ%253D%253D",
);
api.addSearchAlias(
"ySu",
"YouTube Subtitles",
"https://www.youtube.com/results?search_query={0}&sp=EgIoAQ%253D%253D",
);
api.addSearchAlias(
"yCC",
"YouTube Creative Commons",
"https://www.youtube.com/results?search_query={0}&sp=EgIwAQ%253D%253D",
);
api.addSearchAlias(
"y360",
"YouTube 360",
"https://www.youtube.com/results?search_query={0}&sp=EgJ4AQ%253D%253D",
);
api.addSearchAlias(
"yvr",
"YouTube VR",
"https://www.youtube.com/results?search_query={0}&sp=EgPQAQE%253D",
);
api.addSearchAlias(
"y3d",
"YouTube 3D",
"https://www.youtube.com/results?search_query={0}&sp=EgI4AQ%253D%253D",
);
api.addSearchAlias(
"yHDR",
"YouTube HDR",
"https://www.youtube.com/results?search_query={0}&sp=EgPIAQE%253D",
);
api.addSearchAlias(
"yL",
"YouTube Location",
"https://www.youtube.com/results?search_query={0}&sp=EgO4AQE%253D",
);
api.addSearchAlias(
"yP",
"YouTube Purchased",
"https://www.youtube.com/results?search_query={0}&sp=EgJIAQ%253D%253D",
);
api.addSearchAlias("G", "Google", "https://www.google.com/search?q={0}");
api.addSearchAlias(
"gH",
"Google Hour",
"https://www.google.com/search?q={0}&tbs=qdr:h",
);
api.addSearchAlias(
"gsh",
"Google Search History",
"https://myactivity.google.com/myactivity?authuser=0&q={0}",
);
api.addSearchAlias(
"gi",
"Google Images",
"https://www.google.com/search?q={0}&tbm=isch",
);
api.addSearchAlias(
"hN",
"Hacker News",
"https://hn.algolia.com/?q={0}&page=0&prefix=false",
);
api.addSearchAlias(
"pH",
"Product Hunt",
"https://www.producthunt.com/search?q={0}",
);
api.addSearchAlias(
"gh",
"GitHub Repositories",
"https://github.com/search?q={0}&type=repositories",
);
api.addSearchAlias(
"ghC",
"GitHub Commits",
"https://github.com/search?q={0}&type=commits",
);
api.addSearchAlias(
"ghi",
"GitHub Issues",
"https://github.com/search?q={0}&type=issues",
);
api.addSearchAlias(
"ghd",
"GitHub Discussions",
"https://github.com/search?q={0}&type=discussions",
);
api.addSearchAlias(
"ghr",
"GitHub Registry",
"https://github.com/search?q={0}&type=registrypackages",
);
api.addSearchAlias(
"ghm",
"GitHub Marketplace",
"https://github.com/search?q={0}&type=marketplace",
);
api.addSearchAlias(
"ght",
"GitHub Topics",
"https://github.com/search?q={0}&type=topics",
);
api.addSearchAlias(
"ghw",
"GitHub Wiki",
"https://github.com/search?q={0}&type=wikis",
);
api.addSearchAlias(
"ghu",
"GitHub Users",
"https://github.com/search?q={0}&type=users",
);
api.addSearchAlias(
"i",
"Gmail Search",
"https://mail.google.com/mail/u/0/#search/{0}",
);
api.addSearchAlias(
"Y",
"YouTube Search",
"https://www.youtube.com/results?search_query={0}",
);
api.addSearchAlias(
"yH",
"YouTube History",
"https://www.youtube.com/feed/history?query={0}",
);
api.addSearchAlias(
"crm",
"Code Reference MDN",
"https://developer.mozilla.org/en-US/search?q={0}",
);
api.addSearchAlias(
"crdd",
"Code Reference DevDocs",
"http://devdocs.io/#q={0}",
);
api.addSearchAlias("wk", "Wikipedia", "https://en.wikipedia.org/wiki/{0}");
api.addSearchAlias(
"fb",
"Facebook",
"https://www.facebook.com/search/top/?q={0}",
);
api.addSearchAlias("tw", "Twitter", "https://twitter.com/search?q={0}");
api.addSearchAlias(
"ig",
"Instagram Hashtag",
"https://www.instagram.com/explore/tags/",
);
api.addSearchAlias("rd", "Reddit", "https://www.reddit.com/search?q={0}");
// solarized dark
settings.theme = `
.sk_theme {
font-family: Input Sans Condensed, Charcoal, sans-serif;
font-size: 10pt;
background: #002B36;
color: #93A1A1;
}
.sk_theme input {
color: #93A1A1;
}
.sk_theme .url {
color: #268BD2;
}
.sk_theme .annotation {
color: #93A1A1;
}
.sk_theme kbd {
background: #EEE8D5;
color: #111;
}
.sk_theme .omnibar_highlight {
color: #CB4B16;
}
.sk_theme .omnibar_folder {
color: #2AA198;
}
.sk_theme .omnibar_timestamp {
color: #657B83;
}
.sk_theme .omnibar_visitcount {
color: #B58900;
}
.sk_theme .prompt, .sk_theme .resultPage {
color: #93A1A1;
}
.sk_theme .feature_name {
color: #859900;
}
.sk_theme .separator {
color: #859900;
}
.sk_theme #sk_omnibarSearchResult ul li:nth-child(odd) {
background: #002F3B;
}
.sk_theme #sk_omnibarSearchResult ul li.focused {
background: #083D4A;
}
#sk_status, #sk_find {
font-size: 12pt;
}
#sk_keystroke {
background: #002B36;
}
.expandRichHints span.annotation {
color: #93A1A1;
}`;