-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyboard_shortcuts.js
61 lines (51 loc) · 1.54 KB
/
keyboard_shortcuts.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
// ==UserScript==
// @name Recruiterbox Keyboard Shortcuts
// @version 0.1
// @description Some helpful shortcuts for navigating recruiterbox candidate page
// @author Andrew Mitchell
// @include /^https://.*\.recruiterbox\.com/app/.*
// ==/UserScript==
var keyPrefix = 'ctrl+shift+';
function findAndClick(selector) {
var results = $(selector);
if (results.length == 1) {
results[0].click();
} else {
console.log("Unexpected number of results:", results);
}
}
function findAndClickLinkWithText(text) {
findAndClick("a:contains('" + text + "')");
}
function findAndClickButtonWithText(text) {
findAndClick("button:contains('" + text + "')");
}
function bindKey(key, callback) {
Mousetrap.bind(keyPrefix + key, callback);
}
var keyToLinkMapping = {
't': 'New To-do',
'm': 'New Candidate Message',
'n': 'New Internal Note',
'i': 'New Interview'
}
var keyToButtonMapping = {
'a': 'Change Assignee',
's': 'Change Stage'
}
// Load this handy Mousetrap library and do some keybinding
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/mousetrap/1.4.6/mousetrap.min.js', function() {
$.each(keyToLinkMapping, function(key, link) {
bindKey(key, function(e) {
findAndClickLinkWithText(link);
});
});
$.each(keyToButtonMapping, function(key, button) {
bindKey(key, function(e) {
findAndClickButtonWithText(button);
});
});
bindKey('/', function(e) {
$("[name='q']")[0].focus();
});
});